Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #115477
| From | Lawrence D'Oliveiro <ldo@nz.invalid> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Statement-Continuation Rule |
| Date | 2024-02-10 21:20 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <uq8pam$3padl$7@dont-email.me> (permalink) |
| References | <uq1bhn$1lp15$4@dont-email.me> |
How about this:
const SECONDS_PER_MINUTE = 60
const SECONDS_PER_HOUR = 3600
document.getElementById("content").innerHTML =
Array.from
(
function*() /* generate entries */
{
for (let i = 0; i <= 32; ++i)
{
yield i * SECONDS_PER_HOUR / 4
} /*for*/
}(),
function(t) /* format entries as hh:mm */
{
const hours = Math.floor(t / SECONDS_PER_HOUR)
const minutes = Math.floor((t - hours * SECONDS_PER_HOUR) / SECONDS_PER_MINUTE)
return "" + hours + ":" + (minutes < 10 ? "0" : "") + minutes
}
).reduce
(
(sofar, elt) => /* join entries into a single string */
sofar + (sofar != "" ? ", " : "") + elt,
""
)
Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread
Statement-Continuation Rule Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-02-08 01:42 +0000 Re: Statement-Continuation Rule Jon Ribbens <jon+usenet@unequivocal.eu> - 2024-02-08 02:26 +0000 Re: Statement-Continuation Rule Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-02-10 21:20 +0000
csiph-web