What happens when you try to add two arrays together in JavaScript?

preview_player
Показать описание

What happens when you add two arrays together in JavaScript? This weird functionality is important to watch out for, as it is unintuitive and could cause bugs in your code.
Рекомендации по теме
Комментарии
Автор

const bills = [125, 555, 44]
const tips = [54, 96, 32]
for(let i = 0;i < bills.length;i++)
total.push(bills[i] + tips[i])
you can simply loop through the array index to add them

dumptruck
Автор

Could we next time add a solution to solve it? :)

matt.mattox
Автор

How the heck do we add two arrays, numerically, element by element. I tried many suggested options with total failures. Do you have yet another suggestion? I will try that too.

manabsac
Автор

What will Happen, if you create a New array for a+b, and if you Set a Semikolon at the first Position of b. Then the result must be the merged array, right?

aubisoka
Автор

...yes, i know what not to do. Now what am I supposed to do? 🙃

Cun
Автор

What is the proper way to add the arrays together?

chrisparsons
Автор

A surprise to be sure, but not a welcome one.

ivanljujic
join shbcf.ru