Rosamunda
Rosamunda

Reputation: 14980

Uncaught TypeError in JS when trying to use .split()

Why I keep getting the

"Uncaught TypeError: segEnDia.split is not a function"

in this example that I want to make it work?

var cantidadDada = 1000;
var segEnDia = cantidadDada / 86400;
var segEnDiaSplit = segEnDia.split(".");

Thanks!

Upvotes: 0

Views: 282

Answers (1)

ul90
ul90

Reputation: 787

segEnDia is not a string but a number. You have to convert the value to a string. Try this:

var cantidadDada = 1000;
var segEnDia = cantidadDada / 86400;
var segEnDiaSplit = ("" + segEnDia).split(".");

Upvotes: 2

Related Questions