0

JavaScript intermediate quiz

Fill in blanks to make the variable arr3 look like the following: [1, 2, 3, 4, 5, 6, 7, 8]. const arr1 = [1, 2, 3]; const arr2 = [5, 6, 7, 8]; let arr3 = [ …arr1, 4,...arr2];

1st Nov 2024, 4:06 PM
Andra Venkata Ramana Rao
9 ответов
+ 1
I just copy/pasted your snippet to check. It seems you have something that appears on screen like the spread operator `...` but it is not. That was written in the line where <arr3> was defined, next to <arr1>. I removed that `...` before <arr1>, type three dots in there, and it works. let arr3 = [...arr1, 4, ...arr2]; Don't forget to log <arr3> in the console in case it was part of the task requirement :-)
1st Nov 2024, 5:45 PM
Ipang
+ 1
Ipang I found the same thing like the '...' ( buggy ? ) But this code does work and display the correct unpacked array const arr1 = [1, 2, 3]; const arr2 = [5, 6, 7, 8]; let arr3 = [...arr1, 4, ...arr2]; console.log(arr3); // Output: [1, 2, 3, 4, 5, 6, 7, 8] Without the '...' before arr1 // Output [[1,2,3],4,5,6,7,8] and Andra Venkata Ramana Rao I ran that both here and on the online-compiler with same results
1st Nov 2024, 8:17 PM
BroFar
BroFar - avatar
0
It shows wrong
1st Nov 2024, 4:07 PM
Andra Venkata Ramana Rao
0
What is the right one
1st Nov 2024, 4:08 PM
Andra Venkata Ramana Rao
0
The same code in online compiler shows no error. But in quiz it shows wrong Please check and show the key
1st Nov 2024, 5:53 PM
Andra Venkata Ramana Rao
0
Which online compiler? What did you mean key? I had pointed out the part with syntax issue, and provided a workaround....
1st Nov 2024, 6:05 PM
Ipang
0
Keyboard key. Full stop key i am using
1st Nov 2024, 6:08 PM
Andra Venkata Ramana Rao
1st Nov 2024, 6:10 PM
Andra Venkata Ramana Rao
0
In sololearn quiz that bit shows wrong I lost more than 15 hearts. How can i complete the quiz
1st Nov 2024, 6:12 PM
Andra Venkata Ramana Rao