Error in JavaScript | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
0

Error in JavaScript

Heeeeelp... I don't know why, but it doesn't work. https://code.sololearn.com/ct0zw7757cBx/?ref=app

29th Oct 2023, 4:27 PM
ㅤㅤㅤ
ㅤㅤㅤ - avatar
4 Réponses
+ 4
ㅤㅤㅤ , i am not sure if you are aware, that there are 2 different ways, how and when the increment / decrement will be done: >>> increment operators: > a++ is called *post increment*. when using this notation, the value of *a* is used as it is, maybe in an expression, and increment is done *after* this. ++a is called *pre increment*. when using this notation, the value of *a* will be incremented first, and then is maybe used in an expression. According to the description above, the decrement is also carried out in this way.
29th Oct 2023, 6:04 PM
Lothar
Lothar - avatar
+ 1
console.log(arr[a][b]); console.log('\nTest'); a++; b++; console.log(arr[a][b]); b-=2; console.log(arr[a][b]); Or console.log(arr[a][b]); console.log('\nTest'); console.log(arr[++a][++b]); console.log(arr[a][b-=2]);
30th Oct 2023, 7:45 AM
Eduardo Bresolin
Eduardo Bresolin - avatar
+ 1
Eduardo Bresolin It works, thanks!
30th Oct 2023, 8:24 AM
ㅤㅤㅤ
ㅤㅤㅤ - avatar
0
Lothar Yes... but... it has decreased, not increased. And this is not normal...
30th Oct 2023, 8:17 AM
ㅤㅤㅤ
ㅤㅤㅤ - avatar