Funktion greift nicht auf Variable zu...
bearbeitet von
@@dedlfix
> ~~~js, bad
> [a, b] = x > y ? [b, a] : [a, b];
> ~~~
Du meinst `[a, b] = a > b ? [b, a] : [a, b];`{:.language-js}?
Und wenn das öfter vorkommt, schreibst du
~~~JavaScript, bad
[a, b] = a > b ? [b, a] : [a, b];
[c, d] = c > d ? [d, c] : [c, d];
[e, f] = e > f ? [f, e] : [e, f];
~~~
anstatt lesbaren Code
~~~JavaScript
[a, b] = [a, b].sort(compareNumerically);
[c, d] = [c, d].sort(compareNumerically);
[e, f] = [e, f].sort(compareNumerically);
~~~
und einmaliger Definition der Vergleichsfunktion?
LLAP 🖖
--
*„Wer durch Wissen und Erfahrung der Klügere ist, der sollte nicht nachgeben. Und nicht aufgeben.“* —Kurt Weidemann