QUESTION IMAGE
Question
jump to level 1
divide each element in origarray with the corresponding value in offsetarray. store each value in a new array named destinationarray. do not output to the console.
1 let origarray = 40, 50, 60, 70 ; // tests will use different arrays
2 let offsetarray = 2, 5, 8, 4 ; // tests will use different arrays
3 let destinationarray = ;
4
5 / your solution goes here /
6
Step1: Iterate through the arrays
Use a for loop to iterate from 0 to the length of origArray minus 1.
for (let i = 0; i < origArray.length; i++) {
Step2: Perform division and push to destinationArray
Divide the element at index i in origArray by the element at index i in offsetArray and push the result to destinationArray.
destinationArray.push(origArray[i] / offsetArray[i]);
Step3: Close the loop
Close the for loop.
}Snap & solve any problem in the app
Get step-by-step solutions on Sovi AI
Photo-based solutions with guided steps
Explore more problems and detailed explanations
let origArray = [ 40, 50, 60, 70 ];
let offsetArray = [ 2, 5, 8, 4 ];
let destinationArray = [];
for (let i = 0; i < origArray.length; i++) {
destinationArray.push(origArray[i] / offsetArray[i]);
}