Hello everyone happy new year to all.

i want get length of only fractional part of number in java script function.
example if number is 4.321 then length of fractional part is 3. please help me.

thank you

Recommended Answers

Here is the code

<html>
<script lang='javascript'>
function fraclength(num)
{
    alert(num.split(".")[1].length) ;

}

fraclength("54.93934");

</script>
</html>
Jump to Post

All 3 Replies

Here is the code

<html>
<script lang='javascript'>
function fraclength(num)
{
    alert(num.split(".")[1].length) ;

}

fraclength("54.93934");

</script>
</html>

thank you very much. it's working.

Time to learn difference between JSP (Java Server Pages) and JS(JavaScript). Post moved to Java Script section

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.