Mathematics
Algorithms
Logic
Numbers
function getResult(array, operator) { // WARNING! topicstarter gave wrong testcases! switch substract and rest values // to topicstarter: subsract is minus (-), not plus (+) if (!Array.isArray(array) || !array.length) { return false; } var array = array.slice(); var operators = [ 'Rest', 'Substract', 'Multiply', 'Divide' ]; if (operators.indexOf(operator) === -1) { return false; } var res = array.find(function(elem) { // find first number in array return +elem === elem; }); if (res === undefined) { return 0; } var idx = array.indexOf(res); array.splice(0, idx+1); var totalRes = array.reduce(function(acc, elem) { if (+elem !== elem) { return acc; } switch (operator) { case operators[0]: return acc += elem; break; case operators[1]: return acc -= elem; break; case operators[2]: return acc *= elem; break; default: return elem === 0 ? Infinity : acc /= elem; break; } }, res); return totalRes; }
- function getResult(array, operator) {
test :D- // WARNING! topicstarter gave wrong testcases! switch substract and rest values
- // to topicstarter: subsract is minus (-), not plus (+)
- if (!Array.isArray(array) || !array.length) { return false; }
- var array = array.slice();
- var operators = [
- 'Rest',
- 'Substract',
- 'Multiply',
- 'Divide'
- ];
- if (operators.indexOf(operator) === -1) { return false; }
- var res = array.find(function(elem) { // find first number in array
- return +elem === elem;
- });
- if (res === undefined) { return 0; }
- var idx = array.indexOf(res);
- array.splice(0, idx+1);
- var totalRes = array.reduce(function(acc, elem) {
- if (+elem !== elem) {
- return acc;
- }
- switch (operator) {
- case operators[0]:
- return acc += elem;
- break;
- case operators[1]:
- return acc -= elem;
- break;
- case operators[2]:
- return acc *= elem;
- break;
- default:
- return elem === 0 ? Infinity : acc /= elem;
- break;
- }
- }, res);
- return totalRes;
- }
const chai = require("chai"); const assert = chai.assert; const expect = chai.expect; describe("Result:", function() { //Zero let test1 = [0, 1, 2], test2 = [1, 0, 2], test3 = [1, 2, 0], //Negatives test4 = [-1, 1, 2], test5 = [1, -1, 2], test6 = [1, 2, -1], //String test7 = ['a', 1, 2], test8 = [1, 'a', 2], test9 = [1, 2, 'a'], //Empty String test10 = ['', 1, 2], test11 = [1, '', 2], test12 = [1, 2, ''], //Null test13 = [null, 1, 2], test14 = [1, null, 2], test15 = [1, 2, null], //Large array test16 = [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, 29, 30], //Empty array test17 = [], //Null test18 = null, //Empty String test19 = '', //All same test20 = ['', '', ''], test21 = ['a', 'a', 'a'], test22 = [null, null, null], test23 = [0, 0, 0], test24 = [-1, -1, -1], test25 = ['', '', '']; let res1 = getResult(test1, 'Substract'); res2 = getResult(test1, 'Rest'); res3 = getResult(test1, 'Multiply'); res4 = getResult(test1, 'Divide'); res5 = getResult(test2, 'Substract'); res6 = getResult(test2, 'Rest'); res7 = getResult(test2, 'Multiply'); res8 = getResult(test2, 'Divide'); res9 = getResult(test3, 'Substract'); res10 = getResult(test3, 'Rest'); res11 = getResult(test3, 'Multiply'); res12 = getResult(test3, 'Divide'); res13 = getResult(test4, 'Substract'); res14 = getResult(test4, 'Rest'); res15 = getResult(test4, 'Multiply'); res16 = getResult(test4, 'Divide'); res17 = getResult(test5, 'Substract'); res18 = getResult(test5, 'Rest'); res19 = getResult(test5, 'Multiply'); res20 = getResult(test5, 'Divide'); res21 = getResult(test6, 'Substract'); res22 = getResult(test6, 'Rest'); res23 = getResult(test6, 'Multiply'); res24 = getResult(test6, 'Divide'); res25 = getResult(test7, 'Substract'); res26 = getResult(test7, 'Rest'); res27 = getResult(test7, 'Multiply'); res28 = getResult(test7, 'Divide'); res29 = getResult(test8, 'Substract'); res30 = getResult(test8, 'Rest'); res31 = getResult(test8, 'Multiply'); res32 = getResult(test8, 'Divide'); res33 = getResult(test9, 'Substract'); res34 = getResult(test9, 'Rest'); res35 = getResult(test9, 'Multiply'); res36 = getResult(test9, 'Divide'); res37 = getResult(test10, 'Substract'); res38 = getResult(test10, 'Rest'); res39 = getResult(test10, 'Multiply'); res40 = getResult(test10, 'Divide'); res41 = getResult(test11, 'Substract'); res42 = getResult(test11, 'Rest'); res43 = getResult(test11, 'Multiply'); res44 = getResult(test11, 'Divide'); res45 = getResult(test12, 'Substract'); res46 = getResult(test12, 'Rest'); res47 = getResult(test12, 'Multiply'); res48 = getResult(test12, 'Divide'); res49 = getResult(test13, 'Substract'); res50 = getResult(test13, 'Rest'); res51 = getResult(test13, 'Multiply'); res52 = getResult(test13, 'Divide'); res53 = getResult(test14, 'Substract'); res54 = getResult(test14, 'Rest'); res55 = getResult(test14, 'Multiply'); res56 = getResult(test14, 'Divide'); res57 = getResult(test15, 'Substract'); res58 = getResult(test15, 'Rest'); res59 = getResult(test15, 'Multiply'); res60 = getResult(test15, 'Divide'); res61 = getResult(test16, 'Substract'); res62 = getResult(test16, 'Rest'); res63 = getResult(test16, 'Multiply'); res64 = getResult(test16, 'Divide'); res65 = getResult(test17, 'Substract'); res66 = getResult(test17, 'Rest'); res67 = getResult(test17, 'Multiply'); res68 = getResult(test17, 'Divide'); res69 = getResult(test18, 'Substract'); res70 = getResult(test18, 'Rest'); res71 = getResult(test18, 'Multiply'); res72 = getResult(test18, 'Divide'); res73 = getResult(test19, 'Substract'); res74 = getResult(test19, 'Rest'); res75 = getResult(test19, 'Multiply'); res76 = getResult(test19, 'Divide'); res77 = getResult(test20, 'Substract'); res78 = getResult(test20, 'Rest'); res79 = getResult(test20, 'Multiply'); res80 = getResult(test20, 'Divide'); res81 = getResult(test21, 'Substract'); res82 = getResult(test21, 'Rest'); res83 = getResult(test21, 'Multiply'); res84 = getResult(test21, 'Divide'); res85 = getResult(test22, 'Substract'); res86 = getResult(test22, 'Rest'); res87 = getResult(test22, 'Multiply'); res88 = getResult(test22, 'Divide'); res89 = getResult(test23, 'Substract'); res90 = getResult(test23, 'Rest'); res91 = getResult(test23, 'Multiply'); res92 = getResult(test23, 'Divide'); res93 = getResult(test24, 'Substract'); res94 = getResult(test24, 'Rest'); res95 = getResult(test24, 'Multiply'); res96 = getResult(test24, 'Divide'); res97 = getResult(test25, 'Substract'); res98 = getResult(test25, 'Rest'); res99 = getResult(test25, 'Multiply'); res100 = getResult(test25, 'Divide'); /*it("Test", function() { expect(res1, 'Test failed for array given [' + test1 + ']').to.equal(3); }); it("Test", function() { //expect(res2, 'Test failed for array given [' + test2 + ']').to.equal(3); });*/ it("Test", function() { console.log('Substract the array: ', test1); assert.equal(res1, -3); }); it("Test", function() { console.log('Rest the array: ', test1); assert.equal(res2, 3); }); it("Test", function() { console.log('Multiply the array: ', test1); assert.equal(res3, 0); }); it("Test", function() { console.log('Divide the array: ', test1); assert.equal(res4, 0); }); it("Test", function() { console.log('Substract the array: ', test2); assert.equal(res5, -1); }); it("Test", function() { console.log('Rest the array: ', test2); assert.equal(res6, 3); }); it("Test", function() { console.log('Multiply the array: ', test2); assert.equal(res7, 0); }); it("Test", function() { console.log('Divide the array: ', test2); assert.equal(res8, Infinity); }); it("Test", function() { console.log('Substract the array: ', test3); assert.equal(res9, -1); }); it("Test", function() { console.log('Rest the array: ', test3); assert.equal(res10, 3); }); it("Test", function() { console.log('Multiply the array: ', test3); assert.equal(res11, 0); }); it("Test", function() { console.log('Divide the array: ', test3); assert.equal(res12, Infinity); }); it("Test", function() { console.log('Substract the array: ', test4); assert.equal(res13, -4); }); it("Test", function() { console.log('Rest the array: ', test4); assert.equal(res14, 2); }); it("Test", function() { console.log('Multiply the array: ', test4); assert.equal(res15, -2); }); it("Test", function() { console.log('Divide the array: ', test4); assert.equal(res16, -0.5); }); it("Test", function() { console.log('Substract the array: ', test5); assert.equal(res17, 0); }); it("Test", function() { console.log('Rest the array: ', test5); assert.equal(res18, 2); }); it("Test", function() { console.log('Multiply the array: ', test5); assert.equal(res19, -2); }); it("Test", function() { console.log('Divide the array: ', test5); assert.equal(res20, -0.5); }); it("Test", function() { console.log('Substract the array: ', test6); assert.equal(res21, 0); }); it("Test", function() { console.log('Rest the array: ', test6); assert.equal(res22, 2); }); it("Test", function() { console.log('Multiply the array: ', test6); assert.equal(res23, -2); }); it("Test", function() { console.log('Divide the array: ', test6); assert.equal(res24, -0.5); }); it("Test", function() { console.log('Substract the array: ', test7); assert.equal(res25, -1); }); it("Test", function() { console.log('Rest the array: ', test7); assert.equal(res26, 3); }); it("Test", function() { console.log('Multiply the array: ', test7); assert.equal(res27, 2); }); it("Test", function() { console.log('Divide the array: ', test7); assert.equal(res28, 0.5); }); it("Test", function() { console.log('Substract the array: ', test8); assert.equal(res29, -1); }); it("Test", function() { console.log('Rest the array: ', test8); assert.equal(res30, 3); }); it("Test", function() { console.log('Multiply the array: ', test8); assert.equal(res31, 2); }); it("Test", function() { console.log('Divide the array: ', test8); assert.equal(res32, 0.5); }); it("Test", function() { console.log('Substract the array: ', test9); assert.equal(res33, -1); }); it("Test", function() { console.log('Rest the array: ', test9); assert.equal(res34, 3); }); it("Test", function() { console.log('Multiply the array: ', test9); assert.equal(res35, 2); }); it("Test", function() { console.log('Divide the array: ', test9); assert.equal(res36, 0.5); }); it("Test", function() { console.log('Substract the array: ', test10); assert.equal(res37, -1); }); it("Test", function() { console.log('Rest the array: ', test10); assert.equal(res38, 3); }); it("Test", function() { console.log('Multiply the array: ', test10); assert.equal(res39, 2); }); it("Test", function() { console.log('Divide the array: ', test10); assert.equal(res40, 0.5); }); it("Test", function() { console.log('Substract the array: ', test11); assert.equal(res41, -1); }); it("Test", function() { console.log('Rest the array: ', test11); assert.equal(res42, 3); }); it("Test", function() { console.log('Multiply the array: ', test11); assert.equal(res43, 2); }); it("Test", function() { console.log('Divide the array: ', test11); assert.equal(res44, 0.5); }); it("Test", function() { console.log('Substract the array: ', test12); assert.equal(res45, -1); }); it("Test", function() { console.log('Rest the array: ', test12); assert.equal(res46, 3); }); it("Test", function() { console.log('Multiply the array: ', test12); assert.equal(res47, 2); }); it("Test", function() { console.log('Divide the array: ', test12); assert.equal(res48, 0.5); }); it("Test", function() { console.log('Substract the array: ', test13); assert.equal(res49, -1); }); it("Test", function() { console.log('Rest the array: ', test13); assert.equal(res50, 3); }); it("Test", function() { console.log('Multiply the array: ', test13); assert.equal(res51, 2); }); it("Test", function() { console.log('Divide the array: ', test13); assert.equal(res52, 0.5); }); it("Test", function() { console.log('Substract the array: ', test14); assert.equal(res53, -1); }); it("Test", function() { console.log('Rest the array: ', test14); assert.equal(res54, 3); }); it("Test", function() { console.log('Multiply the array: ', test14); assert.equal(res55, 2); }); it("Test", function() { console.log('Divide the array: ', test14); assert.equal(res56, 0.5); }); it("Test", function() { console.log('Substract the array: ', test15); assert.equal(res57, -1); }); it("Test", function() { console.log('Rest the array: ', test15); assert.equal(res58, 3); }); it("Test", function() { console.log('Multiply the array: ', test15); assert.equal(res59, 2); }); it("Test", function() { console.log('Divide the array: ', test15); assert.equal(res60, 0.5); }); it("Test", function() { console.log('Substract the array: ', test16); assert.equal(res61, -463); }); it("Test", function() { console.log('Rest the array: ', test16); assert.equal(res62, 465); }); it("Test", function() { console.log('Multiply the array: ', test16); assert.equal(res63, 2.6525285981219103e+32); }); it("Test", function() { console.log('Divide the array: ', test16); assert.equal(res64, 3.769987628815906e-33); }); it("Test", function() { console.log('Substract the array: ', test17); assert.equal(res65, 0); }); it("Test", function() { console.log('Rest the array: ', test17); assert.equal(res66, 0); }); it("Test", function() { console.log('Multiply the array: ', test17); assert.equal(res67, 0); }); it("Test", function() { console.log('Divide the array: ', test17); assert.equal(res68, 0); }); it("Test", function() { console.log('Substract the array: ', test18); assert.equal(res69, 0); }); it("Test", function() { console.log('Rest the array: ', test18); assert.equal(res70, 0); }); it("Test", function() { console.log('Multiply the array: ', test18); assert.equal(res71, 0); }); it("Test", function() { console.log('Divide the array: ', test18); assert.equal(res72, 0); }); it("Test", function() { console.log('Substract the array: ', test19); assert.equal(res73, 0); }); it("Test", function() { console.log('Rest the array: ', test19); assert.equal(res74, 0); }); it("Test", function() { console.log('Multiply the array: ', test19); assert.equal(res75, 0); }); it("Test", function() { console.log('Divide the array: ', test19); assert.equal(res76, 0); }); it("Test", function() { console.log('Substract the array: ', test20); assert.equal(res77, 0); }); it("Test", function() { console.log('Rest the array: ', test20); assert.equal(res78, 0); }); it("Test", function() { console.log('Multiply the array: ', test20); assert.equal(res79, 0); }); it("Test", function() { console.log('Divide the array: ', test20); assert.equal(res80, 0); }); it("Test", function() { console.log('Substract the array: ', test21); assert.equal(res81, 0); }); it("Test", function() { console.log('Rest the array: ', test21); assert.equal(res82, 0); }); it("Test", function() { console.log('Multiply the array: ', test21); assert.equal(res83, 0); }); it("Test", function() { console.log('Divide the array: ', test21); assert.equal(res84, 0); }); it("Test", function() { console.log('Substract the array: ', test22); assert.equal(res85, 0); }); it("Test", function() { console.log('Rest the array: ', test22); assert.equal(res86, 0); }); it("Test", function() { console.log('Multiply the array: ', test22); assert.equal(res87, 0); }); it("Test", function() { console.log('Divide the array: ', test22); assert.equal(res88, 0); }); it("Test", function() { console.log('Substract the array: ', test23); assert.equal(res89, 0); }); it("Test", function() { console.log('Rest the array: ', test23); assert.equal(res90, 0); }); it("Test", function() { console.log('Multiply the array: ', test23); assert.equal(res91, 0); }); it("Test", function() { console.log('Divide the array: ', test23); assert.equal(res92, Infinity); }); it("Test", function() { console.log('Substract the array: ', test24); assert.equal(res93, 1); }); it("Test", function() { console.log('Rest the array: ', test24); assert.equal(res94, -3); }); it("Test", function() { console.log('Multiply the array: ', test24); assert.equal(res95, -1); }); it("Test", function() { console.log('Divide the array: ', test24); assert.equal(res96, -1); }); it("Test", function() { console.log('Substract the array: ', test25); assert.equal(res97, 0); }); it("Test", function() { console.log('Rest the array: ', test25); assert.equal(res98, 0); }); it("Test", function() { console.log('Multiply the array: ', test25); assert.equal(res99, 0); }); it("Test", function() { console.log('Divide the array: ', test25); assert.equal(res100, 0); }); });
- const chai = require("chai");
- const assert = chai.assert;
- const expect = chai.expect;
- describe("Result:", function() {
- //Zero
- let test1 = [0, 1, 2],
- test2 = [1, 0, 2],
- test3 = [1, 2, 0],
- //Negatives
- test4 = [-1, 1, 2],
- test5 = [1, -1, 2],
- test6 = [1, 2, -1],
- //String
- test7 = ['a', 1, 2],
- test8 = [1, 'a', 2],
- test9 = [1, 2, 'a'],
- //Empty String
- test10 = ['', 1, 2],
- test11 = [1, '', 2],
- test12 = [1, 2, ''],
- //Null
- test13 = [null, 1, 2],
- test14 = [1, null, 2],
- test15 = [1, 2, null],
- //Large array
- test16 = [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, 29, 30],
- //Empty array
- test17 = [],
- //Null
- test18 = null,
- //Empty String
- test19 = '',
- //All same
- test20 = ['', '', ''],
- test21 = ['a', 'a', 'a'],
- test22 = [null, null, null],
- test23 = [0, 0, 0],
- test24 = [-1, -1, -1],
- test25 = ['', '', ''];
let res1 = getResult(test1, 'Substract'),- let res1 = getResult(test1, 'Substract');
- res2 = getResult(test1, 'Rest');
- res3 = getResult(test1, 'Multiply');
- res4 = getResult(test1, 'Divide');
- res5 = getResult(test2, 'Substract');
- res6 = getResult(test2, 'Rest');
- res7 = getResult(test2, 'Multiply');
- res8 = getResult(test2, 'Divide');
- res9 = getResult(test3, 'Substract');
- res10 = getResult(test3, 'Rest');
- res11 = getResult(test3, 'Multiply');
- res12 = getResult(test3, 'Divide');
- res13 = getResult(test4, 'Substract');
- res14 = getResult(test4, 'Rest');
- res15 = getResult(test4, 'Multiply');
- res16 = getResult(test4, 'Divide');
- res17 = getResult(test5, 'Substract');
- res18 = getResult(test5, 'Rest');
- res19 = getResult(test5, 'Multiply');
- res20 = getResult(test5, 'Divide');
- res21 = getResult(test6, 'Substract');
- res22 = getResult(test6, 'Rest');
- res23 = getResult(test6, 'Multiply');
- res24 = getResult(test6, 'Divide');
- res25 = getResult(test7, 'Substract');
- res26 = getResult(test7, 'Rest');
- res27 = getResult(test7, 'Multiply');
- res28 = getResult(test7, 'Divide');
- res29 = getResult(test8, 'Substract');
- res30 = getResult(test8, 'Rest');
- res31 = getResult(test8, 'Multiply');
- res32 = getResult(test8, 'Divide');
- res33 = getResult(test9, 'Substract');
- res34 = getResult(test9, 'Rest');
- res35 = getResult(test9, 'Multiply');
- res36 = getResult(test9, 'Divide');
- res37 = getResult(test10, 'Substract');
- res38 = getResult(test10, 'Rest');
- res39 = getResult(test10, 'Multiply');
- res40 = getResult(test10, 'Divide');
- res41 = getResult(test11, 'Substract');
- res42 = getResult(test11, 'Rest');
- res43 = getResult(test11, 'Multiply');
- res44 = getResult(test11, 'Divide');
- res45 = getResult(test12, 'Substract');
- res46 = getResult(test12, 'Rest');
- res47 = getResult(test12, 'Multiply');
- res48 = getResult(test12, 'Divide');
- res49 = getResult(test13, 'Substract');
- res50 = getResult(test13, 'Rest');
- res51 = getResult(test13, 'Multiply');
- res52 = getResult(test13, 'Divide');
- res53 = getResult(test14, 'Substract');
- res54 = getResult(test14, 'Rest');
- res55 = getResult(test14, 'Multiply');
- res56 = getResult(test14, 'Divide');
- res57 = getResult(test15, 'Substract');
- res58 = getResult(test15, 'Rest');
- res59 = getResult(test15, 'Multiply');
- res60 = getResult(test15, 'Divide');
- res61 = getResult(test16, 'Substract');
- res62 = getResult(test16, 'Rest');
- res63 = getResult(test16, 'Multiply');
- res64 = getResult(test16, 'Divide');
- res65 = getResult(test17, 'Substract');
- res66 = getResult(test17, 'Rest');
- res67 = getResult(test17, 'Multiply');
- res68 = getResult(test17, 'Divide');
- res69 = getResult(test18, 'Substract');
- res70 = getResult(test18, 'Rest');
- res71 = getResult(test18, 'Multiply');
- res72 = getResult(test18, 'Divide');
- res73 = getResult(test19, 'Substract');
- res74 = getResult(test19, 'Rest');
- res75 = getResult(test19, 'Multiply');
- res76 = getResult(test19, 'Divide');
- res77 = getResult(test20, 'Substract');
- res78 = getResult(test20, 'Rest');
- res79 = getResult(test20, 'Multiply');
- res80 = getResult(test20, 'Divide');
- res81 = getResult(test21, 'Substract');
- res82 = getResult(test21, 'Rest');
- res83 = getResult(test21, 'Multiply');
- res84 = getResult(test21, 'Divide');
- res85 = getResult(test22, 'Substract');
- res86 = getResult(test22, 'Rest');
- res87 = getResult(test22, 'Multiply');
- res88 = getResult(test22, 'Divide');
- res89 = getResult(test23, 'Substract');
- res90 = getResult(test23, 'Rest');
- res91 = getResult(test23, 'Multiply');
- res92 = getResult(test23, 'Divide');
- res93 = getResult(test24, 'Substract');
- res94 = getResult(test24, 'Rest');
- res95 = getResult(test24, 'Multiply');
- res96 = getResult(test24, 'Divide');
- res97 = getResult(test25, 'Substract');
- res98 = getResult(test25, 'Rest');
- res99 = getResult(test25, 'Multiply');
res100 = getResult(test25, 'Divide');- res100 = getResult(test25, 'Divide');
- /*it("Test", function() {
- expect(res1, 'Test failed for array given [' + test1 + ']').to.equal(3);
- });
- it("Test", function() {
- //expect(res2, 'Test failed for array given [' + test2 + ']').to.equal(3);
- });*/
- it("Test", function() {
- console.log('Substract the array: ', test1);
assert.equal(res1, 3);- assert.equal(res1, -3);
- });
- it("Test", function() {
- console.log('Rest the array: ', test1);
assert.equal(res2, -3);- assert.equal(res2, 3);
- });
- it("Test", function() {
- console.log('Multiply the array: ', test1);
- assert.equal(res3, 0);
- });
- it("Test", function() {
- console.log('Divide the array: ', test1);
- assert.equal(res4, 0);
- });
- it("Test", function() {
- console.log('Substract the array: ', test2);
assert.equal(res5, 3);- assert.equal(res5, -1);
- });
- it("Test", function() {
- console.log('Rest the array: ', test2);
assert.equal(res6, -1);- assert.equal(res6, 3);
- });
- it("Test", function() {
- console.log('Multiply the array: ', test2);
- assert.equal(res7, 0);
- });
- it("Test", function() {
- console.log('Divide the array: ', test2);
- assert.equal(res8, Infinity);
- });
- it("Test", function() {
- console.log('Substract the array: ', test3);
assert.equal(res9, 3);- assert.equal(res9, -1);
- });
- it("Test", function() {
- console.log('Rest the array: ', test3);
assert.equal(res10, -1);- assert.equal(res10, 3);
- });
- it("Test", function() {
- console.log('Multiply the array: ', test3);
- assert.equal(res11, 0);
- });
- it("Test", function() {
- console.log('Divide the array: ', test3);
- assert.equal(res12, Infinity);
- });
- it("Test", function() {
- console.log('Substract the array: ', test4);
assert.equal(res13, 2);- assert.equal(res13, -4);
- });
- it("Test", function() {
- console.log('Rest the array: ', test4);
assert.equal(res14, -4);- assert.equal(res14, 2);
- });
- it("Test", function() {
- console.log('Multiply the array: ', test4);
- assert.equal(res15, -2);
- });
- it("Test", function() {
- console.log('Divide the array: ', test4);
- assert.equal(res16, -0.5);
- });
- it("Test", function() {
- console.log('Substract the array: ', test5);
assert.equal(res17, 2);- assert.equal(res17, 0);
- });
- it("Test", function() {
- console.log('Rest the array: ', test5);
assert.equal(res18, 0);- assert.equal(res18, 2);
- });
- it("Test", function() {
- console.log('Multiply the array: ', test5);
- assert.equal(res19, -2);
- });
- it("Test", function() {
- console.log('Divide the array: ', test5);
- assert.equal(res20, -0.5);
- });
- it("Test", function() {
- console.log('Substract the array: ', test6);
assert.equal(res21, 2);- assert.equal(res21, 0);
- });
- it("Test", function() {
- console.log('Rest the array: ', test6);
assert.equal(res22, 0);- assert.equal(res22, 2);
- });
- it("Test", function() {
- console.log('Multiply the array: ', test6);
- assert.equal(res23, -2);
- });
- it("Test", function() {
- console.log('Divide the array: ', test6);
- assert.equal(res24, -0.5);
- });
- it("Test", function() {
- console.log('Substract the array: ', test7);
assert.equal(res25, 3);- assert.equal(res25, -1);
- });
- it("Test", function() {
- console.log('Rest the array: ', test7);
assert.equal(res26, -1);- assert.equal(res26, 3);
- });
- it("Test", function() {
- console.log('Multiply the array: ', test7);
- assert.equal(res27, 2);
- });
- it("Test", function() {
- console.log('Divide the array: ', test7);
- assert.equal(res28, 0.5);
- });
- it("Test", function() {
- console.log('Substract the array: ', test8);
assert.equal(res29, 3);- assert.equal(res29, -1);
- });
- it("Test", function() {
- console.log('Rest the array: ', test8);
assert.equal(res30, -1);- assert.equal(res30, 3);
- });
- it("Test", function() {
- console.log('Multiply the array: ', test8);
- assert.equal(res31, 2);
- });
- it("Test", function() {
- console.log('Divide the array: ', test8);
- assert.equal(res32, 0.5);
- });
- it("Test", function() {
- console.log('Substract the array: ', test9);
assert.equal(res33, 3);- assert.equal(res33, -1);
- });
- it("Test", function() {
- console.log('Rest the array: ', test9);
assert.equal(res34, -1);- assert.equal(res34, 3);
- });
- it("Test", function() {
- console.log('Multiply the array: ', test9);
- assert.equal(res35, 2);
- });
- it("Test", function() {
- console.log('Divide the array: ', test9);
- assert.equal(res36, 0.5);
- });
- it("Test", function() {
- console.log('Substract the array: ', test10);
assert.equal(res37, 3);- assert.equal(res37, -1);
- });
- it("Test", function() {
- console.log('Rest the array: ', test10);
assert.equal(res38, -1);- assert.equal(res38, 3);
- });
- it("Test", function() {
- console.log('Multiply the array: ', test10);
- assert.equal(res39, 2);
- });
- it("Test", function() {
- console.log('Divide the array: ', test10);
- assert.equal(res40, 0.5);
- });
- it("Test", function() {
- console.log('Substract the array: ', test11);
assert.equal(res41, 3);- assert.equal(res41, -1);
- });
- it("Test", function() {
- console.log('Rest the array: ', test11);
assert.equal(res42, -1);- assert.equal(res42, 3);
- });
- it("Test", function() {
- console.log('Multiply the array: ', test11);
- assert.equal(res43, 2);
- });
- it("Test", function() {
- console.log('Divide the array: ', test11);
- assert.equal(res44, 0.5);
- });
- it("Test", function() {
- console.log('Substract the array: ', test12);
assert.equal(res45, 3);- assert.equal(res45, -1);
- });
- it("Test", function() {
- console.log('Rest the array: ', test12);
assert.equal(res46, -1);- assert.equal(res46, 3);
- });
- it("Test", function() {
- console.log('Multiply the array: ', test12);
- assert.equal(res47, 2);
- });
- it("Test", function() {
- console.log('Divide the array: ', test12);
- assert.equal(res48, 0.5);
- });
- it("Test", function() {
- console.log('Substract the array: ', test13);
assert.equal(res49, 3);- assert.equal(res49, -1);
- });
- it("Test", function() {
- console.log('Rest the array: ', test13);
assert.equal(res50, -1);- assert.equal(res50, 3);
- });
- it("Test", function() {
- console.log('Multiply the array: ', test13);
- assert.equal(res51, 2);
- });
- it("Test", function() {
- console.log('Divide the array: ', test13);
- assert.equal(res52, 0.5);
- });
- it("Test", function() {
- console.log('Substract the array: ', test14);
assert.equal(res53, 3);- assert.equal(res53, -1);
- });
- it("Test", function() {
- console.log('Rest the array: ', test14);
assert.equal(res54, -1);- assert.equal(res54, 3);
- });
- it("Test", function() {
- console.log('Multiply the array: ', test14);
- assert.equal(res55, 2);
- });
- it("Test", function() {
- console.log('Divide the array: ', test14);
- assert.equal(res56, 0.5);
- });
- it("Test", function() {
- console.log('Substract the array: ', test15);
assert.equal(res57, 3);- assert.equal(res57, -1);
- });
- it("Test", function() {
- console.log('Rest the array: ', test15);
assert.equal(res58, -1);- assert.equal(res58, 3);
- });
- it("Test", function() {
- console.log('Multiply the array: ', test15);
- assert.equal(res59, 2);
- });
- it("Test", function() {
- console.log('Divide the array: ', test15);
- assert.equal(res60, 0.5);
- });
- it("Test", function() {
- console.log('Substract the array: ', test16);
assert.equal(res61, 465);- assert.equal(res61, -463);
- });
- it("Test", function() {
- console.log('Rest the array: ', test16);
assert.equal(res62, -463);- assert.equal(res62, 465);
- });
- it("Test", function() {
- console.log('Multiply the array: ', test16);
- assert.equal(res63, 2.6525285981219103e+32);
- });
- it("Test", function() {
- console.log('Divide the array: ', test16);
- assert.equal(res64, 3.769987628815906e-33);
- });
- it("Test", function() {
- console.log('Substract the array: ', test17);
- assert.equal(res65, 0);
- });
- it("Test", function() {
- console.log('Rest the array: ', test17);
- assert.equal(res66, 0);
- });
- it("Test", function() {
- console.log('Multiply the array: ', test17);
- assert.equal(res67, 0);
- });
- it("Test", function() {
- console.log('Divide the array: ', test17);
- assert.equal(res68, 0);
- });
- it("Test", function() {
- console.log('Substract the array: ', test18);
- assert.equal(res69, 0);
- });
- it("Test", function() {
- console.log('Rest the array: ', test18);
- assert.equal(res70, 0);
- });
- it("Test", function() {
- console.log('Multiply the array: ', test18);
- assert.equal(res71, 0);
- });
- it("Test", function() {
- console.log('Divide the array: ', test18);
- assert.equal(res72, 0);
- });
- it("Test", function() {
- console.log('Substract the array: ', test19);
- assert.equal(res73, 0);
- });
- it("Test", function() {
- console.log('Rest the array: ', test19);
- assert.equal(res74, 0);
- });
- it("Test", function() {
- console.log('Multiply the array: ', test19);
- assert.equal(res75, 0);
- });
- it("Test", function() {
- console.log('Divide the array: ', test19);
- assert.equal(res76, 0);
- });
- it("Test", function() {
- console.log('Substract the array: ', test20);
- assert.equal(res77, 0);
- });
- it("Test", function() {
- console.log('Rest the array: ', test20);
- assert.equal(res78, 0);
- });
- it("Test", function() {
- console.log('Multiply the array: ', test20);
- assert.equal(res79, 0);
- });
- it("Test", function() {
- console.log('Divide the array: ', test20);
- assert.equal(res80, 0);
- });
- it("Test", function() {
- console.log('Substract the array: ', test21);
- assert.equal(res81, 0);
- });
- it("Test", function() {
- console.log('Rest the array: ', test21);
- assert.equal(res82, 0);
- });
- it("Test", function() {
- console.log('Multiply the array: ', test21);
- assert.equal(res83, 0);
- });
- it("Test", function() {
- console.log('Divide the array: ', test21);
- assert.equal(res84, 0);
- });
- it("Test", function() {
- console.log('Substract the array: ', test22);
- assert.equal(res85, 0);
- });
- it("Test", function() {
- console.log('Rest the array: ', test22);
- assert.equal(res86, 0);
- });
- it("Test", function() {
- console.log('Multiply the array: ', test22);
- assert.equal(res87, 0);
- });
- it("Test", function() {
- console.log('Divide the array: ', test22);
- assert.equal(res88, 0);
- });
- it("Test", function() {
- console.log('Substract the array: ', test23);
- assert.equal(res89, 0);
- });
- it("Test", function() {
- console.log('Rest the array: ', test23);
- assert.equal(res90, 0);
- });
- it("Test", function() {
- console.log('Multiply the array: ', test23);
- assert.equal(res91, 0);
- });
- it("Test", function() {
- console.log('Divide the array: ', test23);
- assert.equal(res92, Infinity);
- });
- it("Test", function() {
- console.log('Substract the array: ', test24);
assert.equal(res93, -3);- assert.equal(res93, 1);
- });
- it("Test", function() {
- console.log('Rest the array: ', test24);
assert.equal(res94, 1);- assert.equal(res94, -3);
- });
- it("Test", function() {
- console.log('Multiply the array: ', test24);
- assert.equal(res95, -1);
- });
- it("Test", function() {
- console.log('Divide the array: ', test24);
- assert.equal(res96, -1);
- });
- it("Test", function() {
- console.log('Substract the array: ', test25);
- assert.equal(res97, 0);
- });
- it("Test", function() {
- console.log('Rest the array: ', test25);
- assert.equal(res98, 0);
- });
- it("Test", function() {
- console.log('Multiply the array: ', test25);
- assert.equal(res99, 0);
- });
- it("Test", function() {
- console.log('Divide the array: ', test25);
- assert.equal(res100, 0);
- });
- });