JavaScript Interview Question #38: Can you add multiple arrays in JavaScript?

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 wi…


This content originally appeared on DEV Community and was authored by Coderslang: Become a Software Engineer

js-test-38

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.

Learn Full-Stack JavaScript


This content originally appeared on DEV Community and was authored by Coderslang: Become a Software Engineer


Print Share Comment Cite Upload Translate Updates
APA

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/

MLA
" » JavaScript Interview Question #38: Can you add multiple arrays in JavaScript?." Coderslang: Become a Software Engineer | Sciencx - Thursday May 6, 2021, https://www.scien.cx/2021/05/06/javascript-interview-question-38-can-you-add-multiple-arrays-in-javascript/
HARVARD
Coderslang: Become a Software Engineer | Sciencx Thursday May 6, 2021 » JavaScript Interview Question #38: Can you add multiple arrays in JavaScript?., viewed ,<https://www.scien.cx/2021/05/06/javascript-interview-question-38-can-you-add-multiple-arrays-in-javascript/>
VANCOUVER
Coderslang: Become a Software Engineer | Sciencx - » JavaScript Interview Question #38: Can you add multiple arrays in JavaScript?. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/05/06/javascript-interview-question-38-can-you-add-multiple-arrays-in-javascript/
CHICAGO
" » JavaScript Interview Question #38: Can you add multiple arrays in JavaScript?." Coderslang: Become a Software Engineer | Sciencx - Accessed . https://www.scien.cx/2021/05/06/javascript-interview-question-38-can-you-add-multiple-arrays-in-javascript/
IEEE
" » JavaScript Interview Question #38: Can you add multiple arrays in JavaScript?." Coderslang: Become a Software Engineer | Sciencx [Online]. Available: https://www.scien.cx/2021/05/06/javascript-interview-question-38-can-you-add-multiple-arrays-in-javascript/. [Accessed: ]
rf:citation
» JavaScript Interview Question #38: Can you add multiple arrays in JavaScript? | Coderslang: Become a Software Engineer | Sciencx | 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.

You must be logged in to translate posts. Please log in or register.