I have been working my way through udacity prep, and I am having some setbacks. I’ve decided to review some of the past information I have learned which has lead me to posting this question.
here are the instructions
Write a while
loop that:
- Loop through the numbers 1 to 20
- If the number is divisible by 3, print
"Julia"
- If the number is divisible by 5, print
"James"
- If the number is divisible by 3 and 5, print
"JuliaJames"
- If the number is not divisible by 3 or 5, print the number
here is my code –
while (x <= 20) {
if(x % 3 === 0) {
console.log("Julia");
++x;
} else if(x % 5 === 0) {
console.log("James");
++x;
} else if((x % 3 === 0) && (x % 5 === 0)); {
console.log("JuliaJames");
++x;
} else {
console.log(x);
}} ```
Basically, it's telling me that it's expecting an identifier before the } else { statement. I don't understand what I am doing wrong and how it is any different than this code...
```var runner = "Kendyll";
var position = 2;
var medal;
if(position === 1) {
medal = "gold";
} else if(position === 2) {
medal = "silver";
} else if(position === 3) {
medal = "bronze";
} else {
medal = "pat on the back";
}
console.log(runner + " received a " + medal + " medal.");