Skip to content

feat:add functionality #7

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ex-1.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@
let lightBulbStatus = "On";

// Start coding here.
if (lightBulbStatus === "On") {
console.log(`Light bulb is ${lightBulbStatus}`);
} else {
console.log("Light bulb is OFF");
}
7 changes: 7 additions & 0 deletions ex-2.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,10 @@
let lightBulbStatus = "On";

// Start coding here.
if (lightBulbStatus === "On"){
console.log(`Light Bulb is ${lightBulbStatus}`);
} else if ( lightBulbStatus === "Off"){
console.log(`Light Blub is ${lightBulbStatus}`);
} else if( lightBulbStatus === "Broken"){
console.log(`Light bulb is ${lightBulbStatus}`);
}
10 changes: 9 additions & 1 deletion ex-3.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,12 @@
// Ternary Operator
let lightBulbStatus = "Off";

//Start coding here
//Start coding here
const message =
lightBulbStatus ==="On"
? "Light bulb is On."
: lightBulbStatus === "OFF"
? "Light bulb is Off."
: "Please choose the correct input (On/Off)"

console.log(message);
12 changes: 11 additions & 1 deletion ex-4.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,14 @@
// Switch Statement
let lightBulbStatus = "On";

//Start coding here
//Start coding here
switch (lightBulbStatus) {
case "On":
case "Off":
case "Broken":
console.log(`Light bulb is ${lightBulbStatus}`);
break;
default:
console.log(`มองดูหลอดไฟของคุณพี่ก่อนจ้า`);
break;
}
22 changes: 22 additions & 0 deletions ex-5.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
function calculateStudentGrade(score) {
// Start coding here
}
if (score > 100 || score < 0) {
return "F";
}

if ( score >= 90){
return "A";
}

if (score >= 80){
return "B";
}

if (score >= 70){
return "C";
}

if (score >= 60){
return "D";
}

return " Check your Score";
}

// Example case
let johnGrade = calculateStudentGrade(30);
Expand Down
3 changes: 3 additions & 0 deletions ex-6.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ let favoriteBooks = [];
function addFavoriteBook(bookName) {
// Start coding here !
}
if (bookName.includes("Beauty")){
favoriteBooks.push(bookName);
}

// Example case
addFavoriteBook("Let Me Tell You What I Mean");
Expand Down