0

How to remove each element in an array

I'm making a program, it can remove each last element in an array but it doesn't work like i want how to do this please help me! Thanks before. Here is the code https://code.sololearn.com/WtuCiR6UV5fp/?ref=app

20th Mar 2020, 7:00 AM
Hafizd Jubaidir
Hafizd Jubaidir - avatar
4 Réponses
+ 4
for(let i = myArr.length; i >5; i--) ... should do it
20th Mar 2020, 7:08 AM
Oma Falk
Oma Falk - avatar
+ 6
window.onload = ()=>{ const myArr = ["Dandi","chika","angel","rizki","febian","jajang","eani"]; for(let i = myArr.length; i >= 0; i--){ myArr.splice(i,1); } console.log(myArr); }
20th Mar 2020, 7:10 AM
Cmurio
Cmurio - avatar
+ 4
Tenias mal la condición, por eso no funcionaba la eliminación de cada ítem del arreglo
20th Mar 2020, 7:11 AM
Cmurio
Cmurio - avatar
0
Thanks everyone thank you so much !. The case already solved.
20th Mar 2020, 7:44 AM
Hafizd Jubaidir
Hafizd Jubaidir - avatar