Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
32 changes: 29 additions & 3 deletions starter-code/basic-algorithms.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,33 @@
// Names and Input
let hacker1 = 'Doug'
let hacker2 = prompt("Who is the Navigator?")
let drivLetters = ""
let navLetters = ""
let names = [hacker1, hacker2]

console.log('The driver\'s name is', hacker1)
console.log('The navigator\'s name is', hacker2)

//Conditionals
if (hacker1.length > hacker2.length) {
console.log ('The Driver has the longest name, it\'s',hacker1.length,' characters')
} else if (hacker1.length === hacker2.length) {
console.log('wow, you both got equally long names,',hacker1.length,'characters!')
} else {
console.log('Yo, navigator got the longest name, it has',hacker2.length,'characters!')
}

for (var i = 0; i < hacker1.length; i++){
drivLetters+= hacker1.toUpperCase()[i];
drivLetters+= " ";
}
console.log(drivLetters)

// Lorem ipsum generator
for (var i = hacker2.length -1; i >=0; i--) {
navLetters+= hacker2[i];
}
console.log(navLetters)

sort.names

if (names0 === hacker1){

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For sorting try to apply .localeCompare() or some other sorting method.

console.log('The Driver\'s name goes first')
}