scrimba
Note at 0:05
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

Note at 0:05
AboutCommentsNotes
Note at 0:05
Expand for more info
main.js
run
preview
console
function centuryFromYear(num) {
// write code here.
var x=Math.floor(num/100);
if(num%100 ==0){
return x;
} else {
return x+1;
}
}



/**
* Test Suite
*/
describe('centuryFromYear()', () => {
it('returns current century', () => {
// arrange
const year = 1905;

// act
const result = centuryFromYear(year);

// log
console.log("result 1: ", result);

// assert
expect(result).toBe(20);
});

it('returns current century for edge case of start of century', () => {
// arrange
const year = 1700;

// act
const result = centuryFromYear(year);

// log
console.log("result 2: ", result);

// assert
expect(result).toBe(17);
});
});
Console
"result 1: "
,
20
,
"result 2: "
,
17
,
/index.html
LIVE