Javascript – Given an array of numbers(arr) and the length of the array(n) as arguments, how do you create a tribonacci sequence?
function tribonacci(arr, n){ let sum = 0; for(let i= arr.length-1; i > arr.length-4; i--){ sum += arr[i] } while(arr.length < n){ arr.push(sum); } return arr; } console.log(tribonacci([1, 1, 1], 10)); With ([1, 1, 1], 10) it should log [1, 1,…