Hi dear welcome to "CodePrime" Blog . In this post YOU are going to learn Switch Case Expression Uses In javascript | How to use switch? | JS Tutorial | By Codeprime. First Creat A index.html file Copy This HTML CODE and pest it one your code editor. 2ndly creat switch.js file Then Copy The JS CODE and pest it then open the index.html file with your browser.
HTML CODE
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="/switch.js"></script>
<title>javascript</title>
</head>
<body>
<h2>Javascript Tutorial</h2>
<h3>By Codeprime</h3>
</body>
</html>
JAVASCRIPT CODE
let games= 'football';
switch(games) {
case "throwball":
console.log("i dont like");
break;
case "basketball":
console.log("i like basketball");
break;
case "cricket":
console.log("i dont like criket");
break;
case "football":
console.log("i like football");
break;
default:
console.log("i like other games");
break;
}
0 Comments