+ 2
Could someone explain me how this code works line to line? Thanks.
var two=5; var five=8; var eight=3; var three=two+eight%five; var ten=two*three%eight; alert(ten);
3 Réponses
+ 3
var three=5+3%8;
three=5+3=8;
var ten=5*8%3;
ten=40%3=1
//output is 1
+ 3
I have put comments in your code to explain:
var two=5;
var five=8;
var eight=3;
var three=two+eight%five;
// var three = 5 + 3 % 8
// you do % first and + after that
// 3 % 8 = 3. 5 + 3 = 8. three = 8
alert (three);
var ten=two*three%eight;
// var ten = 5 * 8 % 3
// 5 * 8 = 40. 40 % 3 = 1
alert(ten);
+ 2
multiplication is before modulus and addition is behind?