Skip to content
Advertisement

i want to assign the last element from chars array to the first index of arr array

what is wrong with the for loop logic?

JavaScript

i want to assign the last element from chars array to the first index of arr array .

Advertisement

Answer

if you want to invert the array, in your example :

JavaScript

you can just use array_reverse() like this :

JavaScript

If you still want to create your own loop, you can do something like this :

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement