Finding errors in code with loops in JavaScript

In the following problems, some programmer has written code and may have made mistakes in it. You should check if the code does what is described. If the code does not work correctly, you need fix the errors.

Задание 1

The code should output numbers from 0 to 10:

javascriptfor (let i = 0; i > 10; i++) {
  console.log(i);
}
Задание 2

The code should output numbers from 10 to 0:

javascriptfor (let i = 10; i > 0; i++) {
  console.log(i);
}
Задание 3

The code should output numbers from 10 to 0:

javascriptfor (let i = 10; i == 0; i--) {
  console.log(i);
}
Задание 4

The code should output numbers from 0 to 10:

javascriptlet i = 0;

while (i >= 10) {
  console.log(i);
  i++;
}
Задание 5

The code should find the sum of integers from 1 to 10:

javascriptlet res;

for (let i = 1; i <= 10; i++) {
  res += i;
}

console.log(res);
Задание 6

The code should find the product of integers from 1 to 10:

javascriptlet res = 0;

for (let i = 1; i <= 10; i++) {
  res *= i;
}

console.log(res);
Задание 7

The code should find the sum of the array elements:

javascriptlet arr = ['1', '2', '3', '4', '5'];
let sum = 0;

for (let elem of arr) {
  sum += elem;
}

console.log(sum); // should output 15
Задание 8

The code should find the sum of the array elements:

javascriptlet arr = ['1', '2', '3', '4', '5'];
let sum = '';

for (let elem of arr) {
  sum += +elem;
}

console.log(sum); // should output 15
Задание 9

The code should find the sum of the array elements:

javascriptlet arr = ['1', '2', '3', '4', '5'];
let sum = 0;

for (let elem of arr) {
  sum = +elem;
}

console.log(sum); // should output 15
Задание 10

The code should find the sum of the array elements, however, it always outputs NaN:

javascriptlet arr = ['1', '2', '3', '4', '5'];
let sum = 0;

for (let i = 0; i <= arr.length; i++) {
  sum += +arr[i];
}

console.log(sum); // for some reason outputs NaN
Задание 11

The code should find the sum of the array elements:

javascriptlet arr = ['1', '2', '3', '4', '5'];
let sum = 0;

for (let i = 0; i < arr.length - 1; i++) {
  sum += +arr[i];
}

console.log(sum); // for some reason it doesn't output 15
Задание 12

The code should find the sum of the array elements:

javascriptlet arr = ['1', '2', '3', '4', '5'];
let sum = 0;

for (let i = 0; i < arr.length; i++) {
  sum += +i;
}

console.log(sum); // for some reason it doesn't output 15
Задание 13

The code should square each element of the array:

javascriptlet arr = [1, 2, 3, 4, 5];

for (let elem of arr) {
  elem = elem ** 2;
}

console.log(arr);
Задание 14

The code should fill the array with numbers from 1 to 5:

javascriptlet arr;

for (let i = 1; i <= 5; i++) {
  arr.push(i);
}

console.log(arr);
Задание 15

The code should find the sum of the elements of the object:

javascriptlet obj = {a: 1, b: 2, c: 3};
let sum = 0;

for (let elem in obj) {
  sum += elem;
}

console.log(sum);
Задание 16

The code should find the sum of the elements of the object:

javascriptlet obj = {a: 1, b: 2, c: 3};
let sum = 0;

for (let key in obj) {
  sum = +obj.key;
}

console.log(sum);
Задание 17

The code should check if the array contains the number 3 or not:

javascriptlet arr = [1, 2, 3, 4, 5];
let res = '';

for (let elem of arr) {
  if (elem === 3) {
    res = '+++';
  } else {
    res = '---';
  }
}

console.log(res);
Задание 18

The code should fill the array with numbers from 1 to 5:

javascriptfor (let i = 1; i <= 5; i++) {
  arr.push(i);
}

console.log(arr);
Задание 19

The code should check if the array contains the number 3 or not:

javascriptlet arr = [1, 2, 3, 4, 5];
let res = false;

for (let elem of arr) {
  if (elem === 3) {
    let res = true;
    break;
  }
}

console.log(res);
Задание 20

The code should output only even elements from the array:

javascriptlet arr = [1, 2, 3, 4, 5];

for (let elem of arr) {
  if (elem % 2 = 0) {
    console.log(elem);
  }
}
Задание 21

The code should write to the new array only the odd elements of the old array:

javascriptlet arr = [1, 2, 3, 4, 5, 6, 7, 8, 9];

for (let elem of arr) {
  if (elem % 2 != 0) {
    res.push(elem);
  }
}

console.log(res);