I am coding a simple counter that uses the current date and ads some numbers to it. I want each digit of the final number to be displayed in its own div so I could style them. Here is the code I am working with. I am getting a ‘Undefined’ is not a function (evaluating(‘y.split(“”)’) error, so I don’t know if the code I made is completely broken or just this line is not working.
var counter = setInterval(timedCount,2000);
function timedCount()
{
var x;
var y;
var arrDigit;
var d=new Date();
x=d.getTime();
y=(Math.floor((x-928713600000)/1000))*16-61447952;
var arrDigit = y.split(""); // this is the error line
jQuery.each(arrDigit, function(){
$("#counter").text('<div class="counter-digit">' + this + '</div>');
});
}
Your y is an int. you need to make it string.
Try: