-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction.js
More file actions
28 lines (24 loc) · 713 Bytes
/
Copy pathfunction.js
File metadata and controls
28 lines (24 loc) · 713 Bytes
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
/*function count(value) {
let length:number = value.length;
console.log(value + " contains " + length + " characters");
}
console.log(count("Hello World"));
function countWithoutSpace(value) {
let length: number = value.replace(/\s/g, "").length;
console.log(value + " contains " + length + " characters");
}
console.log(countWithoutSpace("Hello World"));*/
function count(value, spaces) {
var length;
if (spaces == false) {
length = value.replace(/\s/g, "").length;
}
else {
length = value.length;
}
return length;
}
var myCount1 = count("Hello World");
console.log(myCount1);
var myCount2 = count("Hello World", false);
console.log(myCount2);