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
46 changes: 43 additions & 3 deletions starter-code/basic-algorithms.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,47 @@
// Names and Input
const hacker1 = 'Gisela'
console.log ('The driver\'s name is' + ' ' + hacker1)

const hacker2 = prompt ('introduce un nombre')
console.log ('The navigator\'s name is ' + hacker2)

//Conditionals
if (hacker1.length > hacker2.length) {
console.log ('The driver has the longest name, it has '+ hacker1.length + ' characters')
} else if (hacker1.length < hacker2.length) {
console.log('Yo, navigator got the longest name, it has ' + hacker2.length + ' characters')
} else if (hacker1.length === hacker2.length) {
console.log('wow, you both got equally long names, ' +hacker1.length+ ' characters!!')
}
let nombre = hacker1.toUpperCase()
console.log(nombre)
nombre = nombre.split('')
console.log(nombre)

let espacios = ''
for(let i = 0; i < nombre.length; i++){
espacios += nombre[i] + ' '

// Lorem ipsum generator
}
console.log (espacios)
let alrevez = ''

for(let i = hacker1.length - 1; i >= 0; i--){

alrevez += hacker1[i]

}
console.log(alrevez)

let ordenalf = hacker1.localeCompare(hacker2)
if (ordenalf < 0){
console.log('The driver\'s name goes first')
} else if (ordenalf > 0){
console.log('Yo, the navigator goes first definitely')
} else if (ordenalf === 0){
console.log ('What?! You both got the same name?')
}
//crear una matriz (arreglo de un arreglo) donde va a estar ubicado nuestro rover

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Limpiar nuestro código, de cosas que no necesitamos, facilita la lectura para las demás personas que no lo escribieron 👁 con eso, para la próxima intenten hacer el bonus, aun tenían tiempo.

Happy coding! 🤓🖖🏼


//hacer la inversa al forward

//4 evaluar si el rover desea moverse hacia una direccion que esta ocupada
//array.includes revisa las coordenadas si ya estan ocupadas (obstaculos)