Skip to content

Commit 00a3b46

Browse files
committed
for review 4
1 parent 4a7908e commit 00a3b46

File tree

3 files changed

+36
-4
lines changed

3 files changed

+36
-4
lines changed

baotran87/lesson1/challenge1.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
var unitTest = require('./testUtil');
2+
13
function sumMultiples(x, y, z) {
24
let sum = 0;
35
for (let i = 0; i < z; i++)
@@ -71,4 +73,12 @@ console.log(sumMultiples(3, 5, 1000));
7173
console.log(sumEvenFibonacci(4000000));
7274
console.log(largestPrimeFactor(600851475143));
7375
console.log(largestPrimeFactor(16));
74-
console.log(dayOfTheWeek(13, 10, 2022));
76+
console.log(dayOfTheWeek(13, 10, 2022));
77+
78+
unitTest.test('timUocNguyenToLonNhat', () => {
79+
expect(largestPrimeFactor(600851475143)).toBe(6857);
80+
})
81+
82+
unitTest.test('tinhTongSoFibonacciChan', () => {
83+
expect(sumEvenFibonacci(4000000)).toBe(4613731);
84+
})

baotran87/lesson1/practice1.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ function printEvenNumber(x) {
88
function printMultiTable(x) {
99
for (let i = 1; i <= 10; i++)
1010
{
11-
let Row = '';
11+
let row = '';
1212
for (let j = 1; j <= x; j++)
1313
{
1414
let k = i * j;
15-
Row = Row + j.toString().padStart(2) + ' x ' + i.toString().padStart(2) + ' = ' + k.toString().padStart(2) + '|';
15+
row = row + j.toString().padStart(2) + ' x ' + i.toString().padStart(2) + ' = ' + k.toString().padStart(2) + '|';
1616
}
17-
console.log(Row);
17+
console.log(row);
1818
}
1919
}
2020

baotran87/lesson1/testUtil.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
function expect (value) {
2+
return {
3+
toBe: (toBeValue) => {
4+
if (toBeValue === value) {
5+
console.log('Pass!')
6+
} else {
7+
throw new Error('Error!')
8+
}
9+
}
10+
}
11+
}
12+
13+
function test (msg, func) {
14+
try {
15+
func()
16+
console.log(`${msg} ket thuc kiem thu`)
17+
} catch (err) {
18+
console.error(`${msg} Tra lai ket qua loi`)
19+
}
20+
}
21+
22+
module.exports = {expect, test};

0 commit comments

Comments
 (0)