-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
meine loesungen #1
base: master
Are you sure you want to change the base?
Conversation
let quersumme = 0; | ||
for(let n of zahlen){ | ||
if(n > 9){ | ||
n = n+"" // String daraus machen |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
etwas weniger hacky String(n)
for (const nstring of stringArr) { | ||
numVal += parseInt(nstring) | ||
} | ||
numVal = stringArr[0] === '-' ? numVal * -1 : numVal; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hast du das ganze mal mit -94 getestet ;)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw n < 0
wäre eine alternative, gell?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hast du das ganze mal mit -94 getestet ;)?
jap ist mir danach auch eingefallen :-)
let zeichenkette = "Ich bin eine Zeichenkette" | ||
{ | ||
// Neu: | ||
let alternative = zeichenkette => zeichenkette.split('').map((c,i) => i & 1 ? c.toUpperCase() : c.toLowerCase()).join(''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i & 1 ist nice und würde im code golf wohl gegen i % 2 gewinnen. ich persönlich finde aber i%2 schneller verständlich, bzw. sprechender.
quick and dirty