Напишите программу, которая заполняет массив случайными числами на отрезке[-4;4] и считает сумму отрицательных элементов массива.

Ответы

Ответ дал: nineoneonezer
0

let array = [];

negatives = 0;

for(let i = 0; i < 10; i++){

number = Math.floor(Math.random() * (4 - (-4))) + (-4)

 array.push(number);

 if(number < 0){

negatives++;

 }

}

console.log(array, negatives);

Вас заинтересует