-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7570 from jfigueroa24/dev-solutions
#00 - JavaScript
- Loading branch information
Showing
2 changed files
with
158 additions
and
0 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
Roadmap/00 - SINTAXIS, VARIABLES, TIPOS DE DATOS Y HOLA MUNDO/javascript/jfigueroa24.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// https://www.javascript.com/ | ||
// comentario en una linea | ||
|
||
/* | ||
comentario en varias lineas | ||
*/ | ||
|
||
cadenaDeTexto = "Hola"; | ||
var numeroPar = 6; | ||
let decimal = 6.5; | ||
const PI = 3.1416; | ||
esVerdadero = true; | ||
cadenaDeTexto = "Nuevo Hola"; | ||
otraCadenaDeTexto = "Nuevo Hola"; | ||
console.log("Hola Mundo"); | ||
console.log(typeof numeroPar); |
142 changes: 142 additions & 0 deletions
142
Roadmap/01 - OPERADORES Y ESTRUCTURAS DE CONTROL/javascript/jfigueroa24.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
/*OPERADORES*/ | ||
// Operadores aritmeticos | ||
console.log(`Suma: 10 + 3 = ${10 + 3}`); | ||
console.log(`Resta: 10 - 3 = ${10 - 3}`); | ||
console.log(`Producto: 10 * 3 = ${10 * 3}`); | ||
console.log(`Cociente: 10 / 3 = ${10 / 3}`); | ||
console.log(`Residuo: 10 % 3 = ${10 % 3}`); | ||
console.log(`Exponenciacion: 10 ^ 3 = ${10 ** 3}`); | ||
let num = 10; | ||
num++; | ||
console.log(`Incremento: 10 ++ 3 = ${num}`); | ||
num--; | ||
console.log(`Decremento: 10 -- 3 = ${num}`); | ||
|
||
//Operadores de asignación | ||
|
||
let nombre = "Julian Figueroa"; | ||
let x = 20; // Asignacion simple | ||
let y = 10; | ||
console.log((x += y)); // Asignacion con suma | ||
console.log((x -= y)); // Asignacion con resta | ||
console.log((x *= y)); // Asignacion con multiplicacion | ||
console.log((x /= y)); // Asignacion con division | ||
console.log((x %= y)); // Asignacion con modulo | ||
|
||
//Operadores de comparación | ||
|
||
console.log(x == y); // Igualdad | ||
console.log("Hola" === 25); // estricta | ||
console.log(x != y); // diferente | ||
console.log("Hola" !== 25); // diferente estricta | ||
console.log(x > y); // mayor que | ||
console.log(x < y); // menor que | ||
console.log(x >= y); // mayor o igual que | ||
console.log(x <= y); // menor o igual que | ||
|
||
//Operadores de logicos | ||
|
||
console.log("Cat" && "Dog"); | ||
console.log("Cats" && "Cat"); | ||
|
||
// Operadores de tipo | ||
|
||
console.log(typeof 2.5); | ||
|
||
// Operador ternario | ||
|
||
par = 4; | ||
impar = 5; | ||
esPar = impar % 2 == 0 ? "Par" : "Impar"; | ||
console.log(esPar); | ||
|
||
// ESTRUCTURAS DE CONTROL EN JAVASCRIPT | ||
// Condicionales | ||
|
||
value = true; | ||
if (value) { | ||
console.log("Es verdadero"); | ||
} else if (null) { | ||
console.log("Es nulo"); | ||
} else { | ||
console.log("Es falso"); | ||
} | ||
|
||
// Switch | ||
generoPersona = "masculino"; | ||
switch (generoPersona) { | ||
case "masculino": | ||
console.log("El genero es masculino"); | ||
break; | ||
case "femenino": | ||
console.log("El genero es masculino"); | ||
break; | ||
default: | ||
console.log("El genero no está especificado"); | ||
break; | ||
} | ||
|
||
// Bucles | ||
//for | ||
suma = 0; | ||
for (let i = 0; i <= 10; i++) { | ||
// Suma de los numeros hasta el 10 | ||
suma += i; | ||
} | ||
console.log("For: ", suma); | ||
|
||
// while | ||
suma = 0; | ||
i = 0; | ||
while (i <= 10) { | ||
suma += i; | ||
i++; | ||
} | ||
console.log("While: ", suma); | ||
|
||
//do-while | ||
|
||
suma = 0; | ||
i = 0; | ||
do { | ||
suma += i; | ||
i++; | ||
} while (i <= 10); | ||
console.log("Do while: ", suma); | ||
|
||
// Condicionales sobre colecciones | ||
//for ... of | ||
|
||
const frutas = ["Manzana", "Pera", "Mango", "Fresa"]; | ||
|
||
for (const fruta of frutas) { | ||
console.log(`Fruta: ${fruta}`); | ||
} | ||
|
||
//for ... in | ||
|
||
const persona = { | ||
nombre: "Juan", | ||
edad: 30, | ||
ciudad: "Bogotá", | ||
}; | ||
|
||
for (const clave in persona) { | ||
console.log(`${clave}: ${persona[clave]}`); | ||
} | ||
|
||
// try - catch | ||
|
||
try { | ||
dividendo = 10; | ||
divisor = 1; | ||
|
||
if (divisor === 0) { | ||
throw new Error("No es posible dividir entre cero."); | ||
} | ||
console.log(dividendo / divisor); | ||
} catch (error) { | ||
console.error("Error: ", error.message); | ||
} finally { | ||
("Operacion finalizada"); | ||
} |