• API
• FAQ
• Tools
• Archive
daily pastebin goal
11%
SHARE
TWEET

# Untitled

a guest Jan 22nd, 2019 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. // 55: Number - isInteger
2. // To do: make all tests pass, leave the assert lines unchanged!
3. // Follow the hints of the failure messages!
4.
5. describe('`Number.isInteger()` determines if a value is an integer', function(){
6.   it('`isInteger` is a static function on `Number`', function() {
7.     const whatType = 'function';
8.     assert.equal(typeof Number.isInteger, whatType);
9.   });
10.   describe('zero in different ways', function() {
11.     it('0 is an integer', function() {
12.       const zero = 0;
13.       assert(Number.isInteger(zero));
14.     });
15.     it('0.000', function() {
16.       const veryZero = 0.000;
17.       assert(Number.isInteger(veryZero));
18.     });
19.     it('the string "0" is NOT an integer', function() {
20.       const stringZero = null;
21.       assert(Number.isInteger(stringZero) === false);
22.     });
23.   });
24.   describe('one in different ways', function() {
25.     it('0.111 + 0.889', function() {
26.       const rest = 0.889;
27.       assert(Number.isInteger(0.111 + rest));
28.     });
29.     it('0.5 + 0.2 + 0.2 + 0.1 = 1 ... isn`t it?', function() {
30.       const oneOrNot = 0.5 + 0.2 + 0.2 + 0.1;
31.       assert(Number.isInteger(oneOrNot) === false);
32.     });
33.     it('parseInt`ed "1" is an integer', function() {
34.       const convertedToInt = Number.parseInt('1.01');
35.       assert(Number.isInteger(convertedToInt));
36.     });
37.   });
38.   describe('what is not an integer', function() {
39.     it('`Number()` is an integer', function() {
40.       const numberOne = Number();
41.       assert(Number.isInteger(numberOne));
42.     });
43.     it('`{}` is NOT an integer', function() {
44.       const isit = Number.isInteger({});
45.       assert(isit === false);
46.     });
47.     it('`0.1` is not an integer', function() {
48.       const isit = Number.isInteger(0.1);
49.       assert(isit === false);
50.     });
51.     it('`Number.Infinity` is not an integer', function() {
52.       const isit = Number.isInteger(Number.Infinity);
53.       assert(isit === false);
54.     });
55.     it('`NaN` is not an integer', function() {
56.       const isit = Number.isInteger(NaN);
57.       assert(isit === false);
58.     });
59.   });
60. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top