Skip to content

hauptsächlich obj vs json bis u mit aufgabe 4#10

Open
marcorensch wants to merge 6 commits intoibwgr:masterfrom
marcorensch:master
Open

hauptsächlich obj vs json bis u mit aufgabe 4#10
marcorensch wants to merge 6 commits intoibwgr:masterfrom
marcorensch:master

Conversation

@marcorensch
Copy link

aufgabe 4 in einigen zügen schon auf dem weg zur aufgabe 5

console.log(sum(zahlen))

// Imperativ
let summe = zahlen.reduce((sum, val) =>sum + val)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mit imperativ ist gemeint: keine funktionalen konzepte verwenden. sprich: mit for schleife arbeiten.

// das Array sortieren (mit check ob sortBy im obj existiert)
if(sortBy !== null) {
arr.sort((a, b) => {
if (sortBy in a && sortBy in b) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hinweis: der in Operator berücksichtigt nicht ob das "sortBy" property enumerable ist oder nicht. Schöner wäre es hier Object.keys(a).includes(sortBy) zu verwenden.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants