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
document.querySelector('#').addEventListener('click', function(){ | |
nombredefuncion(); | |
}); |
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
// 1 - VARIABLES. | |
var pais = 'Chile'; // String | |
var continente = 'Latino America'; // String | |
var antiguedad = 2018; // Entero | |
var pais_y_continente = pais + ' ' + continente // Cadena |
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
// 1 - VARIABLES. | |
var pais = 'Chile'; // String | |
var continente = 'Latino America'; // String | |
var antiguedad = 2018; // Entero | |
var pais_y_continente = pais + ' ' + continente // Cadena | |
// 2 - CAMBIAR VALOR A VARIABLE A NIVEL GLOBAL // EL VALOR DE pais_y_continente NO SE CAMBIARA. | |
pais = 'Mexico'; |
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
// 3 - VARIABLES LET // LET FUNCIONA A NIVEL DE BLOQUE, NO A NIVEL GLOBAL. | |
//prueba con var | |
var numero = 40; | |
console.log(numero) // Mostrara 40 en consola. | |
if(true){ | |
var numero = 50; | |
console.log(numero) // Mostrara 50 en consola. | |
} |
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
// 4 - CONSTANTES - ES UNA VARIABLE, PERO SU VALOR NUNCA CAMBIARA | |
var web = "ingkf.com"; | |
const ip = "67.23.253.165"; | |
web = "dsfsdf.com"; //el valor cambiara | |
ip = "23123"; // el cambio de valor dara error, ya que ip fue declarada como constante, y estas no pueden cambiar |
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
// OPERADORES | |
var num1 = 10; | |
var num2 = 10; | |
var operacion = num1 + num2; | |
console.log("El resultado es: " + operacion); | |
// TIPO DE DATOS | |
var numero_entero = 50; // Entero | |
var cadena_texto = 'Hola "que" tal' // String |
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
// CONDICIONAL IF | |
// Si A es igual a B entonces haz algo | |
var a = 10; | |
var b = 10; | |
/* | |
//OPERADORES RELACIONALES |
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
// CONDICIONAL SWITCH | |
var edad = 18; | |
var imprime = ""; | |
switch (edad) { | |
case 18: | |
imprime = "Tu edad es 18"; | |
break; | |
case 20: |
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
// BUCLE FOR | |
// BUCLE ES UNA ESTRUCTURA DE CONTROL QUE SE REPITE VARIAS VECES | |
// La variable numero sera el maximo de veces que se repetira el bucle | |
var numero = 100; | |
//Variable i sera el contador; mientras i sea menor o igual a numero(100) se repetira; incrementamos la variable i cada vez que se repita | |
for( var i = 1; i <= numero; i++ ){ | |
console.log("Vamos por el numero: " + i ); | |
} |
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
// BUCLE WHILE | |
// BUCLE WHILE ES MENOS ESTRICTO QUE FOR | |
var year = 2018; | |
// Mientras que year sea igual o menor a 2051 | |
while(year <= 2051){ | |
//Ejecuta esto | |
console.log("Estamos en el año: "+year) | |
//Incrementamos la variable year para que cuando llegue a 2051 se pare el bucle |
OlderNewer