+ 4

Could someone explain me how this code works line to line? Thanks.

var x=[1,2,3,4,5]; for(var i=0;i<4;i++){ x[i]=x[i+1]; if(i==x.length-2){ x[i]=x[0]; } } document.write(x)

4th May 2018, 1:32 PM
Rastislav Romanec
Rastislav Romanec - avatar
3 Antworten
+ 6
nitish Hahaha... I am on mobile but it has a large screen so it is not too bad ☺
4th May 2018, 2:38 PM
cyk
cyk - avatar
+ 4
thanks for all comments
5th May 2018, 4:22 PM
Rastislav Romanec
Rastislav Romanec - avatar
+ 2
Go the JS tab and read the comments. https://code.sololearn.com/WYNeQHDi0D0Q/?ref=app
4th May 2018, 2:32 PM
cyk
cyk - avatar