ING-Alina-Jürgen-Sergej#575
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.
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.
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.
prefer use of loops as per lesson instruction
| } | ||
| console.log(split);*/ | ||
|
|
||
| let splittedName = uppercasedDriver.split(""); |
There was a problem hiding this comment.
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.
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.
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 { |
| } else { | ||
| console.log(`The Driver has the longest name, it has ${hacker1.length} characters`) | ||
| } | ||
| } else { |
|
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