Strings
Data Types
Your task is to remove every second char in a string.
Example:
removeEverySecond('hello world'); // 'hlowrd'
removeEverySecond('how you doing') // 'hwyudig'
function removeEverySecond(str) {
return [...str].filter((_,i) => !(i%2)).join``;
}
const chai = require("chai");
const assert = chai.assert;
describe("Solution", function() {
it("should test for something", function() {
assert.strictEqual(removeEverySecond('hello world'), 'hlowrd');
assert.strictEqual(removeEverySecond('how you doing'), 'hwyudig');
assert.strictEqual(removeEverySecond('abc'), 'ac');
assert.strictEqual(removeEverySecond(''), '');
assert.strictEqual(removeEverySecond('1234 56789 10112314'), '13 68 0134');
});
});