forked from nan-academy/js-training
-
Notifications
You must be signed in to change notification settings - Fork 1
/
multiply.js
28 lines (24 loc) · 930 Bytes
/
multiply.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
'use strict'
/*
* Create a function `multiply` that takes two number arguments
* and returns the result of the multiplication of those two.
* But you must do this without using the operators * or /
*
* @notions Primitive and Operators, Functions, While
*/
// Your code :
//* Begin of tests
const assert = require('assert')
assert.strictEqual(typeof multiply, 'function')
assert.strictEqual(multiply.length, 2)
assert.strictEqual(multiply.toString().includes('Math.imul'), false)
assert.strictEqual(multiply.toString().includes('*'), false)
assert.strictEqual(multiply.toString().includes('/'), false)
assert.strictEqual(multiply(34, 78), 2652)
assert.strictEqual(multiply(123, 0), 0)
assert.strictEqual(multiply(0, -230), 0)
assert.strictEqual(multiply(0, 0), 0)
assert.strictEqual(multiply(123, -22), -2706)
assert.strictEqual(multiply(-22, 123), -2706)
assert.strictEqual(multiply(-22, -123), 2706)
// End of tests */