This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const instructorWithLongestName = function(instructors) { | |
let longestName = ""; | |
for (let i of instructors) { | |
i.name.length > longestName.length && (longestName = i.name); | |
} | |
return longestName; | |
}; | |
console.log(instructorWithLongestName([ | |
{name: "Samuel", course: "iOS"}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const numberOfVowels = function(data) { | |
let count = 0; | |
for (let char of data) { | |
switch(char) { | |
case "a": | |
count++; | |
break; | |
case "e": | |
count++; | |
break; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const conditionalSum = function(values, condition) { | |
let total = 0; | |
for (let val of values) { | |
if (condition === "even") { | |
val % 2 === 0 ? total += val : total += 0; | |
} else if (condition === "odd") { | |
val % 2 !== 0 ? total += val : total += 0; | |
} else { | |
continue; | |
} |
NewerOlder