I'm new to javascript and I have a question . Please help | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

I'm new to javascript and I have a question . Please help

Why does it also print 0? Aren't we saying for i less than 10 print i++ in this case 1? Here's the code : for (let i = 0 ; i <10; i++) { console.log(i); } The output is : 0,1,2,3,4,5,6,7,8,9

15th May 2020, 2:37 PM
Einstein Shilly shally
Einstein Shilly shally - avatar
2 Answers
+ 2
i++ is a post fix means its value will me increments (+1) after it is used like in console.log() function If u use ++i which is a preFix u will not get 0 in ur output because ++i is a preFix and add 1 at the same time if installation in variable .... I hipe u understand Stay home Stay safe
15th May 2020, 2:46 PM
Abhay
Abhay - avatar
0
Then mark it best and make me free from it
15th May 2020, 2:55 PM
Abhay
Abhay - avatar