Post by ApdPost by Steve CarrollPost by ApdThe thing about "switch" is it's designed for this and uses strict
equality on the "case" clause.
[...]
Post by Steve CarrollI'm aware, but I purposely didn't include it in the "incomplete"
Reference doc (there's enough there for a beginner to start crying as
it is). The if/else idea is very 'approachable' so that's why I chose
it... that, and the fact it's more usable for a lot of basic projects.
I'm not writing 'The Complete Guide to JS' here ;)
All understood. I'm only giving my two-penny worth.
Post by Steve CarrollFWIW, this needn't be limited to what I write, if you want to write a
more complete Ref page #2 (with things I left out, i.e. "BigInt" in the
data types) I'd welcome it!
Maybe, but I'm ok just adding to these threads. "BigInt", although
its meaning is clear to me, is another feature I haven't yet
encountered.
Post by Steve CarrollBut I'm not just creating these for this ng so I have more incentive
than you do, given the lack of interest.
Whatever, it's good you're posting them.
I think so... but I'm not sure why ;)
I didn't cover the regex stuff as you suggested, I did...
"We need to use JS' 'split' method and I'm going to apply a bit of
'regex' that I won't be explaining at this point (maybe elsewhere,
later)."
I'm trying to stay around 100 lines or so. I'll be using this:
<https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle>
But my usage will just be some confusing comments ;)
function shuffleArray(array) {
for (let i = array.length - 1; i > 0; i--) {
// generate a random index between 0 and i (i is current index in loop)
const j = Math.floor(Math.random() * (i + 1));
// shuffle indices i and j (j is a random index used for shuffling)
[array[i], array[j]] = [array[j], array[i]];
}
return array;
}
Maybe I'll include the link <shrug>.
Trying to stay 'condensed' and actually 'get somewhere'... I can't cover
all the details. In any event, this will probably be the last project.
Between the refs, the calc and this text generator I've provided enough
basic info to do other simple projects.