Im trying to take an array of numbers and finding the two adjacent numbers with the highest product. So created a function that multiplies the first two indexes od the array and pushes that product to a new array. My code works for the first index positions but stops and doesn't complete the remaining indexes. What am I doing wrong. This is a code signal practice exercise.
Test: inputArray: [3, 6, -2, -5, 7, 3] Output: [18, -12, 10]
function solution(inputArray) {
var newArray = []
for (var i = 0; i < inputArray.length; i++) {
const indexOneAndTwoProduct = inputArray[0] * inputArray[1]
newArray.push(indexOneAndTwoProduct)
inputArray.shift()
}
return newArray
}
console.log(solution([3, 6, -2, -5, 7, 3]));