This content originally appeared on DEV Community and was authored by Coderslang: Become a Software Engineer
Can you add multiple arrays in JavaScript? What’s the output?
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
The function add(x, y, z)
applies the +
operator to the provided arguments. Or, simply put, adds them up.
In line 5 we provide it with 3 arrays.
Whenever you try to add arrays in JavaScript, they will be first converted to strings. Every element is separated from the next one by a comma and a single space. In our case:
1, 2
3, 4
5, 6
Then these strings are concatenated, or “glued” together to make a result.
ANSWER: a string 1, 23, 45, 6
will be printed to the console.
This content originally appeared on DEV Community and was authored by Coderslang: Become a Software Engineer
Coderslang: Become a Software Engineer | Sciencx (2021-05-06T11:40:55+00:00) JavaScript Interview Question #38: Can you add multiple arrays in JavaScript?. Retrieved from https://www.scien.cx/2021/05/06/javascript-interview-question-38-can-you-add-multiple-arrays-in-javascript/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.