Skip to content

Conversation

JueGooss
Copy link

First Iteration done

/*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){

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 {

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"*/

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("");

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("")

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";

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 {

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 {

Choose a reason for hiding this comment

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

prefer explicit condition

Copy link

@MarcoSantonastasi MarcoSantonastasi left a 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

@stale
Copy link

stale bot commented Dec 19, 2019

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.

@stale stale bot added the stale label Dec 19, 2019
@stale
Copy link

stale bot commented Dec 21, 2019

This pull request is closed. Thank you.

@stale stale bot closed this Dec 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy