Closed gstark closed 6 years ago
Good work
for sumOfArray
see if you can use one of the iterating functions.
if (
x === 'a' ||
x === 'A' ||
x === 'e' ||
x === 'E' ||
x === 'i' ||
x === 'I' ||
x === 'o' ||
x === 'O' ||
x === 'u' ||
x === 'U'
) {
return true
} else {
return false
}
}
can be
function isVowel(x) {
return (
x === 'a' ||
x === 'A' ||
x === 'e' ||
x === 'E' ||
x === 'i' ||
x === 'I' ||
x === 'o' ||
x === 'O' ||
x === 'u' ||
x === 'U'
)
}
since
if (condition) {
return true
} else {
return false
}
is the same as
return (condition)
Do you understand how !!~'aeiou'.indexOf(letter)
works? We haven't covered this in class so I want to make sure you understand the idiom if you are going to use it.
function reverse(x) {
let x2 = x.split('')
let x3 = x2.reverse()
let x4 = x3.join('')
return x4
}
You don't need all those temp variables. you can just do x.split('').reverse().join('')
also try to use more expressive variable names than x
or a
and b
Your homework is: Meets Expectations
Objectives
After completing this assignment, you should be able to:
Requirements
hub clone function-junction
cd function-junction
yarn install
(or justyarn
for short)code .
yarn test
src/functions.test.js
and work on functions until tests pass.Explorer Mode
Adventure Mode
String.reverse()
orArray.max()
to solve these problems, try implementing them from scratch.Epic Mode
sum
andmax
functions to take arrays instead of numbers and update the tests so they pass.for
loop or awhile
loop, convert it to use amap
,filter
orreduce
.Additional Resources
Reference the documentation on MDN to find what kind of helpful functions might already be on
Array
andString
in JavaScript.