Reputation: 809
This code:
function foo(){
var x = 5;
var y = "8.8";
var exp1 = typeof(2 * y);
var exp2 = typeof(x + y);
var exp3 = typeof(parsefloat(x + y));
var exp4 = typeof(x + parsefloat(y));
var exp5 = typeof(x + parseint(y));
var exp6 = typeof(x-y);
var exp7 = typeof(x*y);
alert( exp1 + ", " + exp2 + ", " + exp3 + ", " + exp4 + ", " + exp5 + ", " + exp6 + ", " + exp7 + "." );
}
Gives me an "object expected" error on the line starting with var exp3
, character 2.
Edit:
Not necessary, but why is it an error on character 2?
Upvotes: 1
Views: 1440
Reputation: 51030
parsefloat(x + y)
should be
parseFloat(x + y) // capital F
and
parseint(y)
should be
parseInt(y) // capital I
Upvotes: 2
Reputation: 12506
Change parsefloat
and parseint
to parseFloat
and parseInt
respectively.
Upvotes: 1