Skip to content

Ejercicio JS Basic #5

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
35 changes: 33 additions & 2 deletions js/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,37 @@
// Iteration 1: Names and Input
//
let hacker1 = "David";
console.log("El Nombre del conductor es " + hacker1);
let hacker2 = "david";
console.log("El nombre del navegante es " + hacker2);
// Iteration 2: Conditionals

if ( hacker1.length > hacker2.length ) {
console.log("El conductor tiene el nombre más largo, tiene " + hacker1.length + " caracteres");
} else if (hacker1.length < hacker2.length) {
console.log("Parece que el navegante tiene el nombre más largo, tiene " + hacker2.length + " caracteres");
} else if (hacker1.length === hacker2.length) {
console.log("Vaya, ambos tienen nombres igual de largo, " + hacker1.length + " caracteres");
}

// Iteration 3: Loops
var nuevaCadena = "";
for (let i = 0; i < hacker1.length ; i++) {
nuevaCadena += hacker1[i].toUpperCase() + " "
}
console.log(nuevaCadena);
var cadenaInversa = "";
for(let i = hacker2.length - 1; i >= 0; i--) {
cadenaInversa += hacker2[i]
}
console.log(cadenaInversa);


var hacker1Mayus = hacker1.toUpperCase()
var hacker2Mayus = hacker2.toUpperCase()

if (hacker1Mayus > hacker2Mayus) {
console.log("El nombre del conductor va primero.");
} else if (hacker2Mayus > hacker1Mayus) {
console.log("Yo, el navegador va primero definitivamente.");
} else if (hacker1Mayus === hacker2Mayus) {
console.log("¿Qué? ¿Los dos tienen el mismo nombre?");
}