Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

FTWD MIA Rafael Guasp lab-javascript-basic-algorithms#106

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
rguasp wants to merge1 commit intoironhack-labs:masterfromrguasp:master

Conversation

rguasp
Copy link

No description provided.

@ianizaguirre
Copy link

Hi, here is some Feedback.

  1. Here is some feedback for the code block below. There is no purpose forvar sameLength = false; it does not do anything in the code, so I don't know why it was made?
varhacker1="Alexander";varhacker2="Bill";varsameLength=false;if(hacker1.length>hacker2.length){console.log("The Driver has the longest name, it has "+hacker1.length+" characters");}elseif(hacker2.length>hacker1.length){console.log("Yo, navigator got the longest name, it has "+hacker2.length+" characters");}else{sameLength=true;console.log("wow, you both got equally long names, "+hacker1.length+" characters!!");}
  • You could have just written the above code like this and got the same result:
varhacker1="Alexander";varhacker2="Bill";if(hacker1.length>hacker2.length){console.log("The Driver has the longest name, it has "+hacker1.length+" characters");}elseif(hacker2.length>hacker1.length){console.log("Yo, navigator got the longest name, it has "+hacker2.length+" characters");}else{console.log("wow, you both got equally long names, "+hacker1.length+" characters!!");}
  1. The rest of the code:
varshortest;varsame=true;if(hacker1.length<=hacker2.length){shortest=hacker1.length;}else{shortest=hacker2.length;}for(vari=0;i<shortest;i++){if(hacker1[i].toUpperCase()<hacker2[i].toUpperCase()){same=false;console.log("The driver's name goes first");break;}elseif(hacker2[i].toUpperCase()<hacker1[i].toUpperCase()){same=false;console.log("Yo, the navigator goes first definitely");break;}}if(same===true){console.log("What?! You both got the same name");}
  • The rest of that above code should have been written inside of a function. Having If/Else and Loops outside of a function or code block should be avoided since we want to avoid placing things in the Global Scope.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@rguasp@ianizaguirre

[8]ページ先頭

©2009-2025 Movatter.jp