const isEven = n => !(n%2)
Number.prototype.evenOrOdd = function() {return (['Even', 'Odd'][this%2])||'Not an integer'}- const isEven = n => !(n%2)
// Since Node 10, we're using Mocha. // You can use `chai` for assertions. const chai = require("chai"); const assert = chai.assert; // Uncomment the following line to disable truncating failure messages for deep equals, do: // chai.config.truncateThreshold = 0; // Since Node 12, we no longer include assertions from our deprecated custom test framework by default. // Uncomment the following to use the old assertions: // const Test = require("@codewars/test-compat"); describe("evenOrOdd",function() { it("Basic tests",function() { assert.strictEqual(isEven(2), true) assert.strictEqual(isEven(5), false) assert.strictEqual(isEven(7), false) assert.strictEqual(isEven(12), true) }); })
- // Since Node 10, we're using Mocha.
- // You can use `chai` for assertions.
- const chai = require("chai");
- const assert = chai.assert;
- // Uncomment the following line to disable truncating failure messages for deep equals, do:
- // chai.config.truncateThreshold = 0;
- // Since Node 12, we no longer include assertions from our deprecated custom test framework by default.
- // Uncomment the following to use the old assertions:
- // const Test = require("@codewars/test-compat");
- describe("evenOrOdd",function() {
- it("Basic tests",function() {
assert.strictEqual((2).evenOrOdd(), 'Even')assert.strictEqual((3).evenOrOdd(), 'Odd')assert.strictEqual((9.2).evenOrOdd(), 'Not an integer')assert.strictEqual((9).evenOrOdd(), 'Odd')- assert.strictEqual(isEven(2), true)
- assert.strictEqual(isEven(5), false)
- assert.strictEqual(isEven(7), false)
- assert.strictEqual(isEven(12), true)
- });
- })
// Since Node 10, we're using Mocha. // You can use `chai` for assertions. const chai = require("chai"); const assert = chai.assert; // Uncomment the following line to disable truncating failure messages for deep equals, do: // chai.config.truncateThreshold = 0; // Since Node 12, we no longer include assertions from our deprecated custom test framework by default. // Uncomment the following to use the old assertions: // const Test = require("@codewars/test-compat"); describe("Solution", function() { it("should test for something", function() { // Test.assertEquals(1 + 1, 2); // assert.strictEqual(1 + 1, 2); }); });
- // Since Node 10, we're using Mocha.
- // You can use `chai` for assertions.
- const chai = require("chai");
- const assert = chai.assert;
- // Uncomment the following line to disable truncating failure messages for deep equals, do:
- // chai.config.truncateThreshold = 0;
- // Since Node 12, we no longer include assertions from our deprecated custom test framework by default.
- // Uncomment the following to use the old assertions:
- // const Test = require("@codewars/test-compat");
- describe("Solution", function() {
- it("should test for something", function() {
- // Test.assertEquals(1 + 1, 2);
- // assert.strictEqual(1 + 1, 2);
- });
- });
function revstr(str) { let revStr = str.split('').reverse(); let rev = ""; revStr.forEach(i=>{rev += i;}); return rev; }
- function revstr(str) {
i = str.length; newstr = "";while (i > 0) {newstr += str[i - 1]; i--;}return newstr;- let revStr = str.split('').reverse();
- let rev = "";
- revStr.forEach(i=>{rev += i;});
- return rev;
- }
const chai = require("chai"); const assert = chai.assert; describe("Solution", function() { it("return reversed", function() { assert.strictEqual(revstr("My"), "yM"); }); });
- const chai = require("chai");
- const assert = chai.assert;
- describe("Solution", function() {
- it("return reversed", function() {
assert.strictEqual(revstr("ok hello"), "olleh ko");- assert.strictEqual(revstr("My"), "yM");
- });
- });