← Back to all posts
##### Student learning strings

This is how far I got on the following instructions. Can someone help point me in the right direction. I can't figure out how to not include the decimal.

Exercises: Strings (Part 1)
The length method returns how many characters are in a string. However, the method will NOT give us the length of a number. If num = 1001, num.length returns undefined rather than 4.

1. Use type conversion to print the length (number of digits) of an integer.

2. Change num to 123.45.
Modify your code to print out the length of a decimal value EXCLUDING the period.

Example: The number 123.45 has a length of 6 but should print 5 for the number of digits.

1. What if num could be EITHER an integer or a decimal?
```.css-o0gntx{position:absolute;left:-9999px;}.css-1v1ju80{-webkit-align-items:stretch;-webkit-box-align:stretch;-ms-flex-align:stretch;align-items:stretch;border-width:0;border-style:solid;box-sizing:border-box;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-basis:auto;-ms-flex-preferred-size:auto;flex-basis:auto;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;position:relative;outline:none;min-height:0;min-width:0;position:absolute;left:-9999px;}num = "123.45";
The above code will print out 6. It should be 5 because the decimal point is to be ignored. First you need to find if a given number has a decimal point. You can use the `includes` function. if the decimal point is present then take 1 off of the length of the number and display it else display the length of the number string