Switch Statements

Convert the challenge from the previous lesson into a switch statement. Here’s the problem from the previous lesson:

“Declare a variable called `batteryLevel` and assign it a number value between 0 and 100 to represent a percentage of a cell phone battery between 0% and 100%. Write an If/Else If/Else statement where if the battery level is less than 30, the string “Low battery” is logged to the console. And if the battery level is between 31 and 80, the string “Half-full battery” is logged to the console. And finally, if the current battery level doesn’t fit between any of those ranges, the string “Full battery” is logged to the console. Change the value of `batteryLevel` and run your code so that it enters every if/else if/ else block.”

Instructions: 

  1. Click the play button to watch the video lesson.
  2. Watch the lesson as many times as needed.
  3. Code along with the instructor using the integrated code editor in the center of your screen.
  4. You can use the Run button beneath the code editor to test your code.
  5. Output from the code that you have written will appear in the panel on the right side of your screen.

If you get stuck or need assistance, you can click the button below to connect with a tutor. 

For additional questions or technical support, email support@veroskills.com