how do i remove every 3rd element from an array?
var TheArray = ['h', 'e', 'z', 'l', 'l', 'l', 'o']
How do I make this say "hello" without creating a new array?
Try this:
for (var i = 2; i <= TheArray.length; i += 2)
TheArray.splice(i, 1);
If you want a string in the end, just use TheArray.join("")
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With