Skip to content

Finished assignment #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Finished assignment #18

wants to merge 5 commits into from

Conversation

cabrown91
Copy link

It went well, but I don't think it's flawless. I would rate it a 3. I still need work on for loops, I think.

@melicarls
Copy link
Contributor

  • Bottles of Beer: remember to wrap your code in a function! How could you make the starting number of bottles into a variable? Check out the solutions branch if you'd like to see an example of that stretch goal, but I think that you could do it with a bit more time!
  • isPalindrome: On lines 24 and 27, str.length.split('') should just be str.length. Currently, your code throws an error but it works if that change is made.
  • isPrime: Your answer was so close! You had a few syntax issues. Here's a version of your code that runs:
function isPrime(n) {
  if (n===1) {
      return false;
  } else if (n===2) {
      return true;
  } else {
    for(var i = 2; i < n; i++) {
        if(n % i === 0) {
            return false;
        }
    } return true;
  }
}


function primes(max) {
  var primesList = [];
  for (var i=2; i<=max; i++) {
// ^ Initialize i at 2, since it's the smallest prime number and you don't want 0 to make it into the array
    if (isPrime(i)) {
    primesList.push(i);
    }
  }
  return primesList;
}

Great work overall! Make sure that you're constantly testing your code as you write it so you can avoid syntax issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants