const evenOrOdd = n => n%2===0 ? 'even' : 'odd';
const number = prompt("Enter a number: ");if(number % 2 == 0){console.log("The number is even.");}else{console.log("The number is odd.");}- const evenOrOdd = n => n%2===0 ? 'even' : '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("Solution", function() { it("should return even or odd", function() { // Test.assertEquals(1 + 1, 2); assert.strictEqual(evenOrOdd(4), 'even'); assert.strictEqual(evenOrOdd(3), '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;- 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() {- it("should return even or odd", function() {
- // Test.assertEquals(1 + 1, 2);
// assert.strictEqual(1 + 1, 2);- assert.strictEqual(evenOrOdd(4), 'even');
- assert.strictEqual(evenOrOdd(3), 'odd');
- });
- });
Function names should start with lower case.
const should be used instead of var since the function isn't changing.
const greet = () => "Hello World!";
function Greet(){return "Hello World!"}- const greet = () => "Hello World!";
// 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("Hello World!", "Hello World!"); assert.strictEqual("Hello World!", "Hello World!"); }); });
- // 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 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");- 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);- Test.assertEquals("Hello World!", "Hello World!");
- assert.strictEqual("Hello World!", "Hello World!");
- });
- });