<script>
var counter1 = Math.abs(5/160);
var output = counter1;
alert(output);
var counter = output.split('.',1);
alert(counter);
</script>

when i run this code i got the error in firebug..

split is not a function.?

Recommended Answers

All 3 Replies

<script>
var counter1 = Math.abs(5/160);
var output = counter1; 
alert(output);
var counter = String(output).split('.',1);
alert(counter);
</script>

Yes NextCom is correct. In order to use string functions such as split and replace you have implicitly declare the var as a string.

You can also do it this way.

var output = counter1.toString();

Hi NextCom

Your solution worked for me too.. many thanks!

vhexp

Be a part of the DaniWeb community

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