create an array that mimics a clock (javascript) -


How can you create an array of values, for every hour, starting at 12 o'clock at 11 o'clock AM / PM In javascript?

There are millions of ways to do this. Here's one:

  var theHours = []; (Var i = 0; i & lt; = 23; i ++) for {thehours [i] = (i == 0)? "12 o'clock": ((I and LT; 12)? I + "AM": (I12 = 12) + "PM"); } 

, "6", "1 p.m.", "2 p.m.", "3 p.m.", "4 p.m.", "5 p.m."

, "6 AM "," 7 AM "," 8 AM "," 9 AM "," 10 AM "," 11 AM "," 12 PM "," 1 PM "," 2 PM "," 3 PM "," 4 PM "," 5 PM "," 6 PM "," 7 PM "," 8 PM "," 9 PM "," 10 PM "," 11 PM "]

/ html>

Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -