Skip to content
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

Exercise editor linting warns of unexpected symbol when using if ... else if #517

Open
AlbertLeeUCSF opened this issue Apr 16, 2021 · 0 comments

Comments

@AlbertLeeUCSF
Copy link

Inside of my learnr tutorial, I'm getting warnings whenever I use else if. See below (lines 6, 8, 10):
image

Here is the code for the exercise and its solution

{r KC2, exercise=TRUE, exercise.lines=15}
# YOUR WORK HERE
# Subtract 85 from 100 and assign the result to an object named `score`

# If score is 90 or above, assign "A" to an object named `grade`

# Otherwise if the `score` is 80 or above, assign "B" to an object named `grade`

# Otherwise if the `score` is 70 or above, assign "C" to an object named `grade`

# Otherwise if the `score` is 60 or above, assign "D" to an object named `grade`

# Otherwise if the `score` is below 60, assign "Hidden" to an object named `grade`

# Print the value stored in `grade`
{r KC2-solution}
# Subtract 85 from 100 and assign the result to an object named `score`
score = 100 - 85

if (score >= 90){          # If score is 90 or above, assign "A" to an object named `grade`
  grade <- "A"
} else if (score >= 80){   # Otherwise if the `score` is 80 or above, assign "B" to an object named `grade`
  grade <- "B"
} else if (score >= 70){   # Otherwise if the `score` is 70 or above, assign "C" to an object named `grade`
  grade <- "C"
} else if (score >= 60){   # Otherwise if the `score` is 60 or above, assign "D" to an object named `grade`
  grade <- "D"
} else{                   # Otherwise if the `score` is below 60, assign "Hidden" to an object named `grade`
  grade <- "Hidden"
}

# Print the value stored in `grade`
print(grade)

Does anyone know why this is happening?

Additional info from RStudio Community Post

@gadenbuie gadenbuie changed the title Warning: unexpected symbol 'if' when using else if Exercise editor linting warns of unexpected symbol when using if ... else if Jun 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant