0
Javascript rest parameters
function containsAll(arr) { for (let k = 1; k < arguments.length; k++) { let num = arguments[k]; if (arr.indexOf(num) === -1) { return false; } } return true; } let x = [2, 4, 6, 7]; console.log(containsAll(x, 2, 4, 7));//true console.log(containsAll(x, 6, 4, 9));//false why does first array becomes true while the other one is false since they have the nmber arguements?
4 Respuestas
+ 2
The function searches all numbes in the array.
In the first statement all numbers are found, and true is returned.
In the second statement the 9 is not found in the array, so false is returned.
+ 1
so why did the x is in within the ()
0
Its a parameter for the function.
Its assignt to arr.
The other argumeters are accessed via the arguments array.
0
oh thank you very much