Cover photo

The basic - phần 1

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 ảnh

post image

những chỗ nào không có bảng code hiện ra thì mọi người cứ bấm next bỏ qua

post image

khi 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à xong

1. đáp án intro to javascrit

post image
post image

const a = 3

module.exports = a;

như này là thành công và next sang bài tiếp theo

post image
post image
const a = 5;
const b = a;

module.exports = { a, b }
post image
const a = false;
const b = true;

module.exports = { a, b }
post image
const a = "World";
const b = "Hello World"

module.exports = { a,b }
post image
let a = 3;

a = 5;

module.exports = a;
post image
// all shoes are on sale this week!
const shoesCost = 49;

module.exports = shoesCost;

2.đáp án Functions and operators

post image
post image
function getMessage() {
    return "Hello World!";
}

module.exports = getMessage;
post image
function addTwo(input) {
    return input + 2;
}

module.exports = addTwo;
post image
function product(a,b) {
    return a * b;
}

module.exports = product;
post image
function average(a, b, c, d) {
    return average = (a + b + c + d) / 4;
    
}

module.exports = average;
post image
function getRandom() {
    return getRandom = Math.random();
}

module.exports = getRandom;
post image
function getFloor(x) {
    return x = Math.floor(x);
}

module.exports = getFloor;

3. đáp án Conditionals

post image
post image
code bên dưới 

function isEqual(a, b) { return a === b; }

module.exports = isEqual;

post image
function isNotEqual(a, b) {
    if (a !== b) {
        return true;
    }
    else {
        return false;
    }
}

module.exports = isNotEqual;
post image
function isNotEqual(a, b) {
    if (a !== b) {
        return true;
    }
    else {
        return false;
    }
}

module.exports = isNotEqual;
post image
function greater(first, last) {
    if (first > last) {
        return first;
    }
    else if (last > first) {
        return last;
    }
}

module.exports = greater;
post image
function isEnough(cost, money) {
    return money >= cost;
}

module.exports = isEnough;
post image
function canAccess(purchasedSubscription, freeTrial) {
    if (purchasedSubscription) {
        return true;
    } else if (freeTrial) {
        return true;
    } else {
        return false;
    }
}

module.exports = canAccess;

4. đáp án loops

post image
post image
function summation(n) {
    let s = 0;

    for (let i = 1; i <= n; i++) {
        s = s + i;
    }

    return s;
}

module.exports = summation;
post image
function factorial(n) {
    let r = 1;
    for (let i = n; i >= 1; i--) {
        r = r * i;
    }

    return r;
}

module.exports = factorial;
post image
function scream(n) {
    let s = "";
    for(let i = 1; i <= n; i++) {
        s += "a";
    }

    return s;
}

module.exports = scream;
post image
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;
post image
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à được

post image
post image
function isEven(num) {
    isE = num % 2;
    return isE === 0;
}

module.exports = isEven;
post image
function smallerNumber(num1, num2) {
    if (num1 > num2) {
        return num2;
    }
    else {
        return num1;
    }
}

module.exports = smallerNumber;
post image
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;
post image
function checkNumber(num) {
    if (num > 0) {
        return "positive";
    } else if (num === 0) {
        return "zero";
    } else {
        return "negative";
    }
}

module.exports = checkNumber;
post image
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