Skip to content

Commit f7d7803

Browse files
committed
solves challenge-5 in array-methods.js
1 parent 1e43163 commit f7d7803

1 file changed

Lines changed: 25 additions & 1 deletion

File tree

‎assignments/array-methods.js‎

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,34 @@ console.log("$" + ticketPriceTotal);
9191
// Now that you have used .forEach(), .map(), .filter(), and .reduce(). I want you to think of potential problems you could solve given the data set and the 5k fun run theme.
9292
// Try to create and then solve 3 unique problems using one or many of the array methods listed above.
9393

94+
95+
9496
// Problem 1
9597
//It turns out that some of the runners are actually dogs: Gussy, Fidel and Dollie. Please add for each runner whether the runner is a human or a dog.
98+
runners.forEach(runner => {
99+
if(runner.first_name === "Gussy" || runner.first_name === "Fidel" || runner.first_name === "Dollie") {
100+
runner.species = "dog";
101+
} else {
102+
runner.species = "human";
103+
}
104+
console.log(runner.species);
105+
});
96106

97107

98108
// Problem 2
109+
//The runners who ordered an XS shirt are too tiny to run the race. Return an array named that contains only information about the runners that do not have an XS shirt size.
110+
111+
let noXS = runners.filter(runner => {return !(runner.shirt_size === "XS")});
112+
113+
console.log(noXS);
114+
115+
116+
// Problem 3
117+
//The Lazzy company just merged with the Voolia company. Convert each instance of the Lazzy company into the Voolia company and return the result.
118+
runners.forEach(runner => {
119+
if (runner.company_name === "Lazzy") {
120+
return runner.company_name = "Voolia";
121+
}
122+
});
99123

100-
// Problem 3
124+
console.log(runners);

0 commit comments

Comments
 (0)