Created
October 21, 2019 15:34
-
-
Save epjuan21/22fc7865d878b6cd87ac722c72e3da35 to your computer and use it in GitHub Desktop.
Replace the specific value in an array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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