I want to convert two strings to ints to be able to compare them.
The strings are timers so I basically want to convert as below:
timer1 = 00:00:14 // 14
timer2 = 00:00:25 // 25
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Step one is to remove the colons:
Step two is to take the remaining number and turn it into a number.
parseIntwill return 0 for a string like “000014”, so you can use parseFloat:Good luck!
UPDATE: I didn’t consider the base 10 problem… this would work if you simply wanted to compare which time was greater, but to do a more “proper” comparison of real times you might want to convert both to formal
Dateobjects first.