Skip to content

Instantly share code, notes, and snippets.

@desinas
Last active December 20, 2017 08:21
Show Gist options
  • Save desinas/b93c64c17405348609ff07d83a1117c7 to your computer and use it in GitHub Desktop.
Save desinas/b93c64c17405348609ff07d83a1117c7 to your computer and use it in GitHub Desktop.
Julia James Quiz (4-1) from Udacity Frond end developer
/*
* Programming Quiz: JuliaJames (4-1)
*/
//version using an extra string for concatecate the result
var x = 1;
while (x < 21) {
fizzbuzz = ""; //string init in every loop cycle
if (x%3 === 0) fizzbuzz += "Julia"; //concat Julia if x mod 3 equals 0
if (x%5 === 0) fizzbuzz += "James"; //concat James if x mod 5 equals 0
if (!fizzbuzz) fizzbuzz +=x; //if none of the above checks then give x to the string
console.log(fizzbuzz); //output the string
x += 1;
}
@desinas
Copy link
Author

desinas commented Dec 16, 2017

What Went Well

  • Your code should have a variable x with a starting value of 1
  • Your code should include a while loop
  • Your while loop should have a stop condition
  • Your while loop should use a conditional statement
  • Your while loop should increment x by 1 each time it executes
  • Your code should produce the expected output

Feedback: Your answer passed all our tests! Awesome job!

@desinas
Copy link
Author

desinas commented Dec 16, 2017

Revision 3 is a version using an extra string for concatenate the result and then output it.

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