Last active
March 21, 2021 04:42
-
-
Save zapkub/64788f66192c83f00778c44d9537c8e0 to your computer and use it in GitHub Desktop.
Code From Zero Day1 assignment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Assignment A. ทำโปรแกรมตัดเกรด โดย Input เป็น Number | |
// output เป็น ตัวอักษตัวเดียว A, B, C หรือ D | |
// โดยที่ | |
// 80 - 100 = A | |
// 70 - 79 = B | |
// 60 - 69 = C | |
// 50 - 59 = D | |
// Assignment B. ทำโปรแกรมวาด * ให้เป็นรูปข้าวหลามตัด (diamond) | |
// | |
// parameter input เป็น number 5 ถึง 20 | |
// | |
// โปรแกรมทำงานเฉพาะเลขคี่ ถ้าเป็นเลขคู่ให้ print คำว่า error | |
// | |
// ถ้าเป็น 5 output จะเป็น | |
// * | |
// *** | |
// ***** | |
// *** | |
// * | |
// Example Loop 1. | |
// ```js | |
// var n = 20 | |
// for (var i = 0; i < n; i++) { | |
// console.log(i, "Hello") | |
// if (i > 10) { | |
// console.log("Better") | |
// } | |
// for (var j = 0; j < 5; j++) { | |
// console.log(j, "World") | |
// var mynumber = i + j | |
// console.log("mynumber = ", mynumber) | |
// } | |
// } | |
// ``` | |
// Example Loop 2. | |
// ``` | |
// for (var j = 0; j < 10; j++) { | |
// var message = "" | |
// for (var i = 0; i < 20; i++) { | |
// if (i % 2 == 0) { | |
// message = message + " " | |
// } | |
// message = message + "*" | |
// } | |
// console.log(message, j) | |
// } | |
// ``` | |
// ประกาศ map | |
// const x = { | |
// } | |
// การใช้ bracket | |
// function main() { } | |
// for (var i = 0; i < 10; i++) { | |
// } | |
// if (x === 0) { | |
// } | |
// Example การใช้ function และ return | |
// function cube(n) { | |
// return n*n*n | |
// } | |
// var arrayofnumber = [20, 30, 40, 50] | |
// for(var i = 0; i < 4; i++) { | |
// console.log(cube(arrayofnumber[i])) | |
// } | |
// if (cube(arrayofnumber[0]) > 5000) { | |
// console.log('yes') | |
// } | |
// Example If else statement | |
// ```js | |
// function sayHello(lang) { | |
// if (lang == 'th') { | |
// console.log("สวัสดี") | |
// } else if (lang === 'eng') { | |
// console.log("Hello") | |
// } else if (lang === 'jp') { | |
// console.log("Konichiwa") | |
// } else { | |
// console.log("error unsupport language") | |
// } | |
// } | |
// sayHello("th") | |
// sayHello("eng") | |
// sayHello("jp") | |
// ``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment