Skip to content

Instantly share code, notes, and snippets.

@epjuan21
Created October 21, 2019 15:34
Show Gist options
  • Save epjuan21/22fc7865d878b6cd87ac722c72e3da35 to your computer and use it in GitHub Desktop.
Save epjuan21/22fc7865d878b6cd87ac722c72e3da35 to your computer and use it in GitHub Desktop.
Replace the specific value in an array
//Replace the specific value in an array
var fruits = [“banana”, “apple”, “orange”, “watermelon”, “apple”, “orange”, “grape”, “apple”];
fruits.splice(0, 2, “potato”, “tomato”);
console.log(fruits); // returns [“potato”, “tomato”, “orange”, “watermelon”, “apple”, “orange”, “grape”, “apple”]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment