0

Accessing a character in a string?

I am making a timer. I need to insert a ":" in between minutes and hours. it will look something like this: <input value=456 placeholder="00:00"></input>

2nd Aug 2018, 3:52 PM
Joshua Morgan
Joshua Morgan - avatar
6 odpowiedzi
+ 8
Suppose the name of your string is s. Then you can do this: s.charAt (0)+":"+s.slice (1) P.s if the first number is less than 10 you need to add a zero before it . like for input 456 it will be 04:56
2nd Aug 2018, 5:19 PM
Mitali
Mitali - avatar
+ 9
Ok. ... ... What exactly do you need help with again?? ^_^
2nd Aug 2018, 3:55 PM
Valen.H. ~
Valen.H. ~ - avatar
+ 8
Joshua Morgan Only strings have that method.
4th Aug 2018, 12:01 PM
Valen.H. ~
Valen.H. ~ - avatar
+ 1
I dont know how to insert colon in middle of hour and minutes.. I have tried finding the lessons but I can't
2nd Aug 2018, 3:57 PM
Joshua Morgan
Joshua Morgan - avatar
0
does this work for input integers or only strings? I get the error message "d.charAt is not a function"
4th Aug 2018, 1:05 AM
Joshua Morgan
Joshua Morgan - avatar
0
how can I access char in a line of input values to insert colon? With an array?
5th Aug 2018, 1:39 PM
Joshua Morgan
Joshua Morgan - avatar