repl.it
@MIhm7904/

ProblemSet5

Nodejs

Problem Set 5: Arrays

fork
loading
Files
  • index.js
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//Create an array with the names of different types of fruits and save it to a variable.
//Write code to access the third item in the fruit array and save it to a new variable.
//Overwrite the fruit at the last position in the array with a new string.  It can be anything you want.
//Be sure to test your code is doing what you think it is doing by console.log() ing throughout.

//1
const myFavFruits = ["Cherries", "Blueberries", "Peaches", "Watermelon"]

console.log(myFavFruits)

//2
const familyFavFruit = (myFavFruits[2])
console.log(familyFavFruit)

//3
console.log(myFavFruits.splice(3,1, "Apples", "Pears"))
console.log(myFavFruits)