0

Am I right understand, that first x=1 put in arr[1], so we get arr[3+1]=4 and in last arr[0] =2 + arr[1] = 7(4+3) = 9?

https://code.sololearn.com/WICJsUN8lg2j/?ref=app

22nd Oct 2020, 10:52 AM
Тимур Завьялов
Тимур Завьялов - avatar
4 odpowiedzi
+ 2
You're right that x = 1 so arr[x] is arr[1]. However, arr[x] = arr[x+1] here it means to assign arr[x+1] to arr[x], so arr[x] has the value of arr[x+1]. x = 1, which means arr[1] = arr[2]. Here arr[1] is 7 since arr[2] is 7. For the last statement you're right.
22nd Oct 2020, 11:05 AM
你知道規則,我也是
你知道規則,我也是 - avatar
+ 1
No. x=1,. Arr[x] = Arr[x+1] => Arr[1] = Arr[x+1] = 7 document.write (arr[0] + arr[1]); Arr[0] + Arr[1] = 2 + 7 = 9. Value at Index x+1=2, i.e value 7 is assigned in Array index at x (i.e 1) so Array is now is [2,7,7]
22nd Oct 2020, 11:06 AM
Jayakrishna 🇮🇳
0
I hope, that I am right a words))
22nd Oct 2020, 10:53 AM
Тимур Завьялов
Тимур Завьялов - avatar
0
Thanks for correct me:)
22nd Oct 2020, 11:28 AM
Тимур Завьялов
Тимур Завьялов - avatar