- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharrayOfObjects.js
More file actions
Latest commit
34 lines (19 loc) · 721 Bytes
/
Copy patharrayOfObjects.js
File metadata and controls
34 lines (19 loc) · 721 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
letanimalSounds=[];
// sensationalist story
animalSounds.push({animal: "cat",sound: "meow"})
animalSounds.push({animal: "dog",sound: "bark"})
animalSounds.push({animal: "bird",sound: "tweet"})
animalSounds.push({animal: "mouse",sound: "squeak"})
console.log("all animals")
animalSounds.forEach((element)=>{
console.log(element.animal,element.sound)
})
console.log("")
console.log("animal by name: cat")
letcurrent=animalSounds.find(element=>element.animal=="cat")
console.log(current.animal,current.sound)
console.log("")
console.log("animal by sound: bark")
current=animalSounds.find(element=>element.sound=="bark")
console.log(current.animal,current.sound)
console.log("")