function evenOrOdd(n) { // here n takes input return (n % 2 == 0) ? 'Even' // if number remainder is 0 then even : (n != parseInt(n)) ? 'Not an integer' // if n is not a integer then not an integer : 'Odd' // else odd }
Number.prototype.evenOrOdd = function() {return (['Even', 'Odd'][this%2])||'Not an integer'- function evenOrOdd(n) { // here n takes input
- return (n % 2 == 0) ? 'Even' // if number remainder is 0 then even
- : (n != parseInt(n)) ? 'Not an integer' // if n is not a integer then not an integer
- : 'Odd' // else odd
- }
// 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(evenOrOdd(2), 'Even') assert.strictEqual(evenOrOdd(3), 'Odd') assert.strictEqual(evenOrOdd(9.2), 'Not an integer') assert.strictEqual(evenOrOdd(9), 'Odd') }); })
- // 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(evenOrOdd(2), 'Even')
- assert.strictEqual(evenOrOdd(3), 'Odd')
- assert.strictEqual(evenOrOdd(9.2), 'Not an integer')
- assert.strictEqual(evenOrOdd(9), 'Odd')
- });
- })
for (let a = 6; a < 16; a++) { console.log("Matthew is gay"); }
var b = 5;var a = 6;do {- for (let a = 6; a < 16; a++) {
- console.log("Matthew is gay");
a++;} while(a<16);- }
// 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);
- });
- });