Create a variable "resultArray" (array). Create variables “first” = 1, “second” = 2, “senseOfLife” = 42. Using the .push () array method, add “first” to the array first, then “second”. After that, using the .unshift () method, add the “senseOfLife” variable. What is the error here?

var resultArray = [] var first = [1]; var second = [2]; var senseOfLife = [42]; resultArray.push('first'); resultArray.push('second'); resultArray.unshift('senseOfLife'); 

    1 answer 1

     var resultArray = [] var first = 1; var second = 2; var senseOfLife = 42; resultArray.push(first); resultArray.push(second); resultArray.unshift(senseOfLife); 

    Square brackets were redundant when creating variables. And quotes in the arguments of the methods.