Fundamentals
Strings
For provided string return the reversed string.
Examples:
1)
Input:
abc
Output:
cba
Input:
123
Output:
321
Input:
Hello World!
Output:
!dlroW olleH
const reverseStr = s => [...s].reverse().join("") console.log(reverseStr("Lorem ipsum dolor sit amet!"))
const reverseStr = str => Array.from(str).reverse().join("")- const reverseStr = s => [...s].reverse().join("")
console.log(reverseStr('hello world'));- console.log(reverseStr("Lorem ipsum dolor sit amet!"))
const chai = require("chai"); const assert = chai.assert; describe("Solution", function() { it("should test for something", function() { assert.strictEqual(reverseStr('abc'), 'cba'); assert.strictEqual(reverseStr('123'), '321'); assert.strictEqual(reverseStr('a1b2c3'), '3c2b1a'); assert.strictEqual(reverseStr('Hello World!'), '!dlroW olleH'); assert.strictEqual(reverseStr('Lorem ipsum dolor sit amet!'), '!tema tis rolod muspi meroL'); }); });
- const chai = require("chai");
- const assert = chai.assert;
- describe("Solution", function() {
- it("should test for something", function() {
- assert.strictEqual(reverseStr('abc'), 'cba');
- assert.strictEqual(reverseStr('123'), '321');
- assert.strictEqual(reverseStr('a1b2c3'), '3c2b1a');
- assert.strictEqual(reverseStr('Hello World!'), '!dlroW olleH');
- assert.strictEqual(reverseStr('Lorem ipsum dolor sit amet!'), '!tema tis rolod muspi meroL');
- });
- });