# The basic - phần 1 **Published by:** [meteosrds](https://paragraph.com/@cryptovuive/) **Published on:** 2022-12-14 **URL:** https://paragraph.com/@cryptovuive/the-basic-ph-n-1 ## Content sau khi đăng ký xong và vào trong thì nó sẽ có giao diện như này mọi người chọn như trên ảnhnhững chỗ nào không có bảng code hiện ra thì mọi người cứ bấm next bỏ quakhi có bảng code hiện ra thì mọi người chỉ cần nhìn cái tên như số 1 và copy đúng đoạn code ở các đáp án bên dưới để paste vào 2 và chạy run test là xong1. đáp án intro to javascritconst a = 3module.exports = a; như này là thành công và next sang bài tiếp theoconst a = 5; const b = a; module.exports = { a, b } const a = false; const b = true; module.exports = { a, b } const a = "World"; const b = "Hello World" module.exports = { a,b } let a = 3; a = 5; module.exports = a; // all shoes are on sale this week! const shoesCost = 49; module.exports = shoesCost; 2.đáp án Functions and operatorsfunction getMessage() { return "Hello World!"; } module.exports = getMessage; function addTwo(input) { return input + 2; } module.exports = addTwo; function product(a,b) { return a * b; } module.exports = product; function average(a, b, c, d) { return average = (a + b + c + d) / 4; } module.exports = average; function getRandom() { return getRandom = Math.random(); } module.exports = getRandom; function getFloor(x) { return x = Math.floor(x); } module.exports = getFloor; 3. đáp án Conditionalscode bên dưới function isEqual(a, b) { return a === b; } module.exports = isEqual;function isNotEqual(a, b) { if (a !== b) { return true; } else { return false; } } module.exports = isNotEqual; function isNotEqual(a, b) { if (a !== b) { return true; } else { return false; } } module.exports = isNotEqual; function greater(first, last) { if (first > last) { return first; } else if (last > first) { return last; } } module.exports = greater; function isEnough(cost, money) { return money >= cost; } module.exports = isEnough; function canAccess(purchasedSubscription, freeTrial) { if (purchasedSubscription) { return true; } else if (freeTrial) { return true; } else { return false; } } module.exports = canAccess; 4. đáp án loopsfunction summation(n) { let s = 0; for (let i = 1; i <= n; i++) { s = s + i; } return s; } module.exports = summation; function factorial(n) { let r = 1; for (let i = n; i >= 1; i--) { r = r * i; } return r; } module.exports = factorial; function scream(n) { let s = ""; for(let i = 1; i <= n; i++) { s += "a"; } return s; } module.exports = scream; function scream(n) { let returnStr = ""; returnStr += "a"; oddeven = n % 2; if (0 === oddeven) { for (let i = n - 1; i >= 1; i--) { oe = i % 2; if (oe === 0) { returnStr += "a"; } else { returnStr += "A"; } } } else { for (let i = n - 1; i >= 1; i--) { oe = i % 2; if (oe === 0) { returnStr += "A"; } else { returnStr += "a"; } } } return returnStr; } module.exports = scream; function topDouble(value, top) { let val = value; let r = val; while (val < top) { r = val; val *= 2; } return r; } module.exports = topDouble; 5. đáp án Practice Problems 1 có 5 cái cứ bấm next là đượcfunction isEven(num) { isE = num % 2; return isE === 0; } module.exports = isEven; function smallerNumber(num1, num2) { if (num1 > num2) { return num2; } else { return num1; } } module.exports = smallerNumber; const fakeName = require('./fakeName'); const message = ` Hello, ${fakeName}! You left a package at the office today. You can pick up tomorrow at 10am, ${fakeName}. If not I will drop it off this weekend. Goodbye ${fakeName}! `; module.exports = message; function checkNumber(num) { if (num > 0) { return "positive"; } else if (num === 0) { return "zero"; } else { return "negative"; } } module.exports = checkNumber; function maxSum(num) { if (num < 0) { return 0; } let r = 0; for (let i = 1; i <= num; i++) { r += i; } return r; } module.exports = maxSum; kết thúc phần 1 có thể bấm đây qua phần 2 của basic luôn - link ## Publication Information - [meteosrds](https://paragraph.com/@cryptovuive/): Publication homepage - [All Posts](https://paragraph.com/@cryptovuive/): More posts from this publication - [RSS Feed](https://api.paragraph.com/blogs/rss/@cryptovuive): Subscribe to updates - [Twitter](https://twitter.com/meteosrds): Follow on Twitter