-
Notifications
You must be signed in to change notification settings - Fork 5.8k
ING-Alina-Jürgen-Sergej #575
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
Conversation
/*Iteration 2: Conditionals | ||
2.1. Depending on which name is longer, print: - The Driver has the longest name, it has XX characters or - Yo, navigator got the longest name, it has XX characters or - Wow, you both got equally long names, XX characters!*/ | ||
|
||
if (hacker1.length >=hacker2.length){ |
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.
could be greatly simplified by extracting the condition as an expression to use in the if else branching
} else { | ||
console.log(`The Driver has the longest name, it has ${hacker1.length} characters`) | ||
} | ||
} else { |
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.
prefer an explicit condition. see above comment
|
||
/*Iteration 3: Loops | ||
3.1 Print all the characters of the driver's name, separated by a space and in capitals i.e. "J O H N"*/ | ||
|
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.
prefer use of loops as per lesson instruction
} | ||
console.log(split);*/ | ||
|
||
let splittedName = uppercasedDriver.split(""); |
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.
for native string methods prefer method concatenation
//3.2 Print all the characters of the navigator's name, in reverse order. i.e. "nhoJ"// | ||
|
||
|
||
let reversedName = hacker2.split("").reverse().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.
prefer loops as per lesson instructions
|
||
//3.3 Depending on the lexicographic order of the strings, print: - The driver's name goes first. - Yo, the navigator goes first definitely. - What?! You both got the same name?// | ||
|
||
let abc = "abcdefghijklmnopqrstuvwxyz"; |
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.
ERROR: this is not the correct solution because it does not respect the lexicographic order
if (hacker1.length >=hacker2.length){ | ||
if (hacker1.length == hacker2.length){ | ||
console.log(`Wow, you both got equally long names, ${hacker1.length} characters!`) | ||
} else { |
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.
prefer explicit condition
} else { | ||
console.log(`The Driver has the longest name, it has ${hacker1.length} characters`) | ||
} | ||
} else { |
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.
prefer explicit condition
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.
Should be cleaned up a bit.
If else branching particularly
Up to bonus 2
This pull request has been automatically marked as stale because it didn't have any recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This pull request is closed. Thank you. |
First Iteration done