Skip to content

Instantly share code, notes, and snippets.

/**
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;
console.log('Hello World)
console.log('Hello')
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}`
);
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(
// 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.
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;
@QuocCao-dev
QuocCao-dev / ex1.js
Created September 24, 2022 08:23
solutions
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;
var name = "Francis";
var lastname = "Jones"
var age = 23;
var obj
function createObject(name,lastname,age){
obj = {
name:name,
lastname:lastname,
age:age,
}
function greeting(name){
if(name === undefined){
name = 'user'
}
return 'Hello '+ name;
}
console.log(greeting())