-
Notifications
You must be signed in to change notification settings - Fork 0
/
solution0086.js
48 lines (32 loc) · 1.09 KB
/
solution0086.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
*String Methods Series*
--------------- 8 Kyu - Remove String Spaces ------------------
Instructions:
Simple, remove the spaces from the string, then return the resultant string.
-------------
Sample Tests
const chai = require("chai");
const assert = chai.assert;
chai.config.truncateThreshold=0;
describe("Basic tests",() =>{
it("Fixed Tests", () => {
assert.strictEqual(noSpace('8 j 8 mBliB8g imjB8B8 jl B'), '8j8mBliB8gimjB8B8jlB');
assert.strictEqual(noSpace('8 8 Bi fk8h B 8 BB8B B B B888 c hl8 BhB fd'), '88Bifk8hB8BB8BBBB888chl8BhBfd');
assert.strictEqual(noSpace('8aaaaa dddd r '), '8aaaaaddddr');
});
});
--------------
PREP
Parameters: a string
Return: the string with spaces removed
Example: '8 j 8 mBliB8g imjB8B8 jl B' => '8j8mBliB8gimjB8B8jlB'
Psuedo Code:
-replaceAll(/\s/g, '');
-we, that didn't work and neither did replaceAll(' ', ''), so I guess this challenge was written before ES6
-try .split(' ').join('')
Lessons learned:
x.replace(regex, '') was in the solutions. So perhaps
*/
function noSpace(x){
return x.split(' ').join('');
}