refactor: Renamed js to nodejs

- feat: Added util module
This commit is contained in:
Aerex
2019-12-01 12:30:20 -05:00
parent 294f16e5da
commit 5518fdbe91
4 changed files with 24 additions and 12 deletions

View File

@@ -17,6 +17,8 @@ Note:
Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [231, 231 1]. For the purpose of this problem, assume that your function returns 0 when the reversed integer overflows.
*/
const { assert } = require('../../util/js');
/**
* @param {number} x
* @return {number}
@@ -40,18 +42,21 @@ const reverse = function(x) {
* Output: 321
*/
x = 123;
console.log(reverse(x));
sol = 321;
assert(reverse(x) === sol, 'Output: 321');
/* Test Case 2
* Input: -123
* Output: -321
*/
x = -123;
console.log(reverse(x));
sol = -321
assert(reverse(x) === sol, 'Output: -321');
/* Test Case 3
* Input: 120
* Output: 21
*/
x = 120;
console.log(reverse(x));
sol = 21;
assert(reverse(x) == sol, 'Output: 21');