JOLee83 / assignments

Suncoast Developers Guild Homework
0 stars 0 forks source link

Week 05 Day 2 - Function Junction #17

Closed gstark closed 6 years ago

gstark commented 6 years ago

Objectives

After completing this assignment, you should be able to:

Requirements

  1. Fork this repository to your own account.
  2. Change into your training directory
  3. Clone your repository: hub clone function-junction
  4. Change into your project's directory: cd function-junction
  5. Install the dependencies: yarn install (or just yarn for short)
  6. Open in Code: code .
  7. Start the test runner: yarn test
  8. Open src/functions.test.js and work on functions until tests pass.
  9. Commit and push your work to GitHub.
  10. Turn in the URL to your GitHub repo.

Explorer Mode

Adventure Mode

Epic Mode

Additional Resources

Reference the documentation on MDN to find what kind of helpful functions might already be on Array and String in JavaScript.

JOLee83 commented 6 years ago

https://github.com/JOLee83/function-junction.git

gstark commented 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

gstark commented 6 years ago

Your homework is: Meets Expectations

Awesome Work!