Skip to content

Commit fd40b97

Browse files
committed
StringingCharactersTogether: ExercisesP.1
1 parent 2adaf07 commit fd40b97

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

stringing-characters-together/exercises/part-one.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,22 @@ let num = 1001;
22

33
//Returns 'undefined'.
44
console.log(num.length);
5-
65
//Use type conversion to print the length (number of digits) of an integer.
7-
6+
if (String(num).includes("t")){
7+
console.log(String(num.length +4))
8+
}else {
9+
(console.log(String(num).length))
10+
}
811
//Follow up: Print the number of digits in a DECIMAL value (e.g. num = 123.45 has 5 digits but a length of 6).
9-
12+
let nums = 867.5309;
13+
if (String(nums).includes('f')){
14+
console.log(String(nums.length +2))
15+
} else {
16+
(console.log(String(nums).length -1))
17+
}
1018
//Experiment! What if num could be EITHER an integer or a decimal? Add an if/else statement so your code can handle both cases.
19+
if (String(nums).includes(".")){
20+
console.log(String(nums).length -1);
21+
} else {
22+
console.log(String(nums).length);
23+
}

0 commit comments

Comments
 (0)