Skip to content
Closed
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
34 changes: 31 additions & 3 deletions starter-code/basic-algorithms.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,35 @@
// Names and Input
let hacker1 = "Alex"
console.log(`The driver's name is ${hacker1}`)

let hacker2 = "Eren"

//Conditionals
console.log(`The navigator's name is ${hacker2}`)


// Lorem ipsum generator
if(hacker1.length > hacker2.length){
console.log(`hacke1 has the longest name it has ${hacker1.length} characters`)
} else if(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!!`)
}



var x = hacker1.toUpperCase().split('').join(' ')
console.log(x)

var y = hacker2.split('').reverse().join('')
console.log(y)

// console.log(y.revers())

var total = [hacker1, hacker2]

console.log(total.sort())

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

this function should return only 1 value (the person who comes first). One way to have done this is to do this console.log(total.sort()[0]). Another thing you could have done is use the localeCompare() function.


function checkPalindrom(str) {
return str == str.split('').reverse().join('');
}

checkPalindrom("eye")