File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed
stringing-characters-together/exercises Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -2,9 +2,22 @@ let num = 1001;
2
2
3
3
//Returns 'undefined'.
4
4
console . log ( num . length ) ;
5
-
6
5
//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
+ }
8
11
//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
+ }
10
18
//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
+ }
You can’t perform that action at this time.
0 commit comments