method madness

by trentHarlem

JavaScript

const repeater = (str,num) => str.repeat(num)

//console.log()
console.log(repeater('poo',10))
const capitalize = str => {
array = str.split(" ")
return array.map(n=>n.charAt(0).toUpperCase()+n.substring(1)).join(' ')
}

//------

const findLongest = str => {
array = str.split(" ")
return array.map(n=>n.length).reduce((a, b) => Math.max(a, b))
}



console.log(capitalize("The quick white fox jumped around the massive dog"));
console.log(findLongest("The quick white fox jumped around the massive dog"), 7);