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
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 driverName='Ismael'
console.log(`The drivers is ${driverName}`)
const navigatorName = prompt("Dime tu nombre")
console.log(`The navigators name is: ${navigatorName}`)

if(driverName.length > navigatorName.length){
console.log(`The Driver has the longest name, it has ${driverName.length} characters`)
} else if(driverName.length < navigatorName.length){
console.log(`Yo, navigator got the longest name, it has ${navigatorName.length} characters`)
} else{
console.log(`wow, you both got equally long names, ${driverName.length} characters!!`)
}

//Conditionals
let nuevoName = '';
for (i =0; i < driverName.length; i++){
nuevoName += driverName[i] + ' '
}

console.log(nuevoName.toUpperCase()) //Bien, pero si notan les va a sobrar un espacio al final. Pueden removerlo con un .slice(0,-1) o un .trim()
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bien, pero si notan les va a sobrar un espacio al final. Pueden removerlo con un .slice(0,-1) o un .trim()


// Lorem ipsum generator
let nuevoN='' //Traten de ser más explícito en los nombres de las variables, así va a ser más fácil entender qué hacen
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Traten de ser más explícitos en los nombres de las variables, así va a ser más fácil entender qué hacen

for(j=1;j <= navigatorName.length ; j++){
nuevoN += navigatorName[navigatorName.length - j]
}
console.log(nuevoN)

if(driverName < navigatorName){
console.log(`The driver's name goes first`)
} else if(driverName > navigatorName){
console.log(`Yo, the navigator goes first definitely`)
} else{
console.log(`What?! You both got the same name?`)
}