forked from remarcmij/JavaScript1_examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharrays.js
More file actions
30 lines (14 loc) · 749 Bytes
/
arrays.js
File metadata and controls
30 lines (14 loc) · 749 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
'use strict'
let favoriteAnimals = ['blowfish', 'capricorn', 'giraffe'];
favoriteAnimals.push("turtle");
console.log(favoriteAnimals);
favoriteAnimals.splice(1, 0, "meerkat");
console.log("The new value of the array is the initial value with two new elements added blowfish ,meerkat ,capricorn ,giraffe ,turtle");
console.log(favoriteAnimals);
console.log("The array has a length of " + favoriteAnimals.length);
favoriteAnimals.splice(3,1);
console.log(favoriteAnimals);
console.log("The item you're looking for is at index : " + favoriteAnimals.indexOf("meerkat"));
// we can use the property typeOf to locate a certain element within an array *Can also be used in strings
favoriteAnimals.splice(1, 1);
console.log(favoriteAnimals);