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
| function greeting(name){ | |
| if(name === undefined){ | |
| name = 'user' | |
| } | |
| return 'Hello '+ name; | |
| } | |
| console.log(greeting()) |
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
| var name = "Francis"; | |
| var lastname = "Jones" | |
| var age = 23; | |
| var obj | |
| function createObject(name,lastname,age){ | |
| obj = { | |
| name:name, | |
| lastname:lastname, | |
| age:age, | |
| } |
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
| const subLength = (string, character) => { | |
| let arr = []; // lưu index của 2 phần tử sẽ gặp | |
| for (let i = 0; i < string.length; i++) { | |
| if (string[i] === character) { | |
| arr.push(i); | |
| } | |
| } | |
| if (arr.length !== 2) return 0; | |
| return arr[1] - arr[0] + 1; |
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
| function kiemtra(mon1, mon2, mon3, khuVuc, doiTuong, diemChuan) { | |
| if (mon1 * mon1 * mon3 === 0) return "Rớt"; | |
| let tongDiem = mon1 + mon2 + mon3; | |
| const diemCongThemKhuVuc = { | |
| A: 2, | |
| B: 1, | |
| C: 0.5, | |
| }[khuVuc]; | |
| tongDiem += diemCongThemKhuVuc; |
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
| // 9 | |
| const removeEven1 = (arr) => arr.filter((el) => el % 2 !== 0); | |
| const removeEven2 = (arr) => arr.filter((el) => el % 2); | |
| removeEven1([1, 2, 4, 5, 10, 6, 3]); | |
| // 10 | |
| const capitalize = (words) => | |
| words.map((el) => el.charAt(0).toUpperCase() + el.slice(1)); | |
| // 11. |
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
| const players = [ | |
| { jersey: 56, name: "Djounte Murray", position: "Point guard", PPG: 2.6 }, | |
| { jersey: 98, name: "Dennis Rodman", position: "Small Forward", PPG: 10.8 }, | |
| { jersey: 1, name: "Michael Jordan", position: "Small Forward", PPG: 345.6 }, | |
| { jersey: 2, name: "Lebron James", position: "Shooting Guard", PPG: 26.7 }, | |
| { jersey: 33, name: "Patrick Ewing", position: "Center", PPG: 20.2 }, | |
| ]; | |
| const loopName = (value) => | |
| console.log( |
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
| let firstName = "Nguyen"; | |
| let lastName = "Nhan"; | |
| let age = "24"; | |
| let job = "software engineering"; | |
| let salary = "100"; | |
| console.log( | |
| `My name is ${firstName} ${lastName}, i'm ${age} years old. I work as ${job} and make ${salary}` | |
| ); |
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
| console.log('Hello') |
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
| console.log('Hello World) |
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
| /** | |
| 1. Create a variable named `myAge`, and set it equal to your age as a number. | |
| Write a comment that explains this line of code. | |
| */ | |
| // my current age | |
| const myAge = 26; | |
| // early age | |
| let earlyYears = 2; |
NewerOlder