array["Hi","I","Hate","Love","You"];
how can I return "Hi I Love You" and delete the index "Hate".
Can I do this using Slice? From what I know if I use slice such as below:
array.slice(2,3);
It will return only "Hate" instead of getting rid of it, which is what I want.
There is very similar function (language-wise) thats doing what you need
const array = ["Hi","I","Hate","Love","You"];
array.splice(2,1);
console.log(array);
With a little upgrade, you can ask your V8 about if someone likes you or not. Just say his/her name loud and click on Run code snippet. The first response is true, you cannot repeat it for the same person.
const array = ["Hi","I","Hate","Love","You"];
let i=0;
if (Math.random() > 0.5) {
i++;
}
array.splice(2+i,1);
console.log(array);
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