-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathq35.js
More file actions
35 lines (23 loc) · 1.22 KB
/
q35.js
File metadata and controls
35 lines (23 loc) · 1.22 KB
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
31
32
33
34
35
// Animals: Think of at least three different animals that have a common characteristic. Store the names of these animals in a list, and then use a for loop to print out the name of each animal.
// • Modify your program to print a statement about each animal, such as A dog would make a great pet.
// • Add a line at the end of your program stating what these animals have in common. You could print a sentence such as Any of these animals would make a great pet!
// const animals = ['Dogs', 'Cats', 'Rabbits'];
// for (let i = 0; i < animals.length; i++) {
// console.log(animals[i]);
// }
// console.log("");
// for (let i = 0; i < animals.length; i++) {
// console.log(`A ${animals[i].toLowerCase()} would make a great pet.`);
// }
// console.log("They are all common household pets.");
// console.log("Any of these animals would make a great pet!");
const animals = ["Dogs" , "Cat" , "Rabbits"];
animals.forEach(function(animal){
console.log(animal);
})
console.log("");
animals.forEach(function(animal){
console.log(`A ${animal.toLowerCase()} would make a greak pet.`)
})
console.log("They are all common household pets.");
console.log("Any of these animals would make a great pet!");