-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathq13.ts
More file actions
21 lines (16 loc) · 926 Bytes
/
q13.ts
File metadata and controls
21 lines (16 loc) · 926 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// Your Own Array: Think of your favorite mode of transportation, such as a motorcycle or a car, and make a list that stores several examples. Use your list to print a series of statements about these items, such as “I would like to own a Honda motorcycle.”
export default function q13() {
console.log("\n");
// Define an array of modes of transportation
let modesOfTransportations: string[] = ["Bike", "Car", "Train", "Plane"];
// Print each mode with a statement using a for loop
for (let i = 0; i < modesOfTransportations.length; i++) {
console.log("I would like to own a " + modesOfTransportations[i] + ".");
}
console.log("\n");
// Print each mode with a statement using forEach method
modesOfTransportations.forEach(function(modeOfTransportation) {
console.log("I would like to own a " + modeOfTransportation + ".");
});
}
q13();