Article

Switch statements

https://cdn.jsdelivr.net/npm/[email protected]/dist/js.cookie.min.js
Copy to clipboard

Switch statements gives the developer a way to execute different things based on the value of a single variable.

Suppose a user gives us an exam grade and we are required to give feed back on how he performed, we can use a switch statement to code this functionality: https://raw.githubusercontent.com/finsweet/jqueryCourse/main/conditionals/ex6.js?actionable=true In the above example we initialized the grade variable with a 'C' but it should be noted that JavaScript/Jquery provides functions to collect user inputs from input boxes. We will learn about this later.

<script>
$(document).ready(function(){
  XT1
});
</script>
Copy to clipboard
Send to Live Demo

Live demo

<script>    
$(document).ready(function() {
  XT1
});
</script>
<script>
  
</script>
Copy to clipboard
Press the Run Demo button to execute the scripts above.
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Your browser is too small

Resize your browser to be at least 769px wide.