Devil Raily Devil Raily - 24 days ago 4
Javascript Question

indexOf is not a function

I' am currently working with the following code. In the console it's throwing

Uncaught TypeError: TotalAccountBalance.indexOf is not a function

I don't know what else to do. Searching didn't help much.

var CurrentPreservedBalance, CurrentGeneralAccountBalance, TotalAccountBalance;
CurrentPreservedBalance = '20.56';
CurrentGeneralAccountBalance = '20.56';
if( CurrentPreservedBalance && CurrentGeneralAccountBalance ){
TotalAccountBalance = +CurrentPreservedBalance + +CurrentGeneralAccountBalance;
console.log( TotalAccountBalance.indexOf('.') );
} else {


indexOf() is a method of Strings, not Numbers.

console.log( TotalAccountBalance.toString().indexOf('.') );