This file contains hidden or 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('#boton').addEventListener('click', function(){ | |
| traerDatos(); | |
| }); | |
| function traerDatos(){ | |
| let url = `https://mindicador.cl/api/uf`; | |
| const api = new XMLHttpRequest(); | |
| api.open('GET', url, true); | |
| api.send(); |
This file contains hidden or 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('#boton').addEventListener('click', function(){ | |
| traer() | |
| }); | |
| function traer(){ | |
| fetch('https://randomuser.me/api') | |
| .then( res => res.json()) | |
| .then( data => { | |
| console.log(data.results['0']) | |
| contenido.innerHTML = ` |
This file contains hidden or 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
| /* | |
| PARAMETRO DE TIPO REST, SOLO LE DIMOS DOS VALORES A LA FUNCION (fruta1 y fruta2) | |
| EL RESTO DE LOS VALORES SE GUARDARAN EN ( resto_de_frutas ) | |
| LA FUNCION REST SE USA CON TRES PUNTOS | |
| */ | |
| function listadoFrutas(fruta1, fruta2, ...resto_de_frutas){ | |
| console.log("Fruta 1: ", fruta1); | |
| console.log("Fruta 2: ", fruta2); | |
| console.log("Resto: ", resto_de_frutas); |
This file contains hidden or 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
| /* | |
| FUNCIONES ANONIMAS | |
| Y CALLBACKS | |
| */ | |
| var pelicula = function(nombre){ | |
| return "La pelicula es: "+nombre; | |
| } | |
| function sumame(num1, num2, sumaYmuestra, sumaPorDos){ |
This file contains hidden or 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
| /* | |
| AMBITO DE LAS VARIABLES | |
| */ | |
| function holaMundo(texto){ | |
| //VARIABLE DENTRO DE FUNCION, QUE NO PODRA SER LLAMADA FUERA DE ESTA FUNCION | |
| var hola_mundo = "Texto dentro de funcion"; | |
| console.log(texto); |
This file contains hidden or 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
| /* | |
| TRANSFORMACION DE TEXTOS | |
| */ | |
| var numero = 444; | |
| var texto1 = "Hola, bienvenido."; | |
| var texto2 = "Es muy buen curso"; | |
| // TRANSFORMAR A STRING CON LA FUNCION toString | |
| var numero_a_string = numero.toString(); |
This file contains hidden or 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
| /* | |
| PLANTILLAS DE TEXTO | |
| */ | |
| var nombre = prompt("Dime tu nombre"); | |
| var apellidos = prompt("Dime tus apellidos"); | |
| var texto = ` | |
| <h1> Hola que tal </h1> | |
| <h3> Mi Nombre es: ${nombre} </h3> |
This file contains hidden or 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
| // Arrays, Arreglos, Matrices | |
| var nombres = [ "Fabian", //Indice 0 | |
| "Victor", //Indice 1 | |
| "Patricio", //Indice 2 | |
| "Eduardo", //Indice 3 | |
| 52, //Indice 4 | |
| true //Indice 5 | |
| ]; | |
This file contains hidden or 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. Pida 6 numeros por pantalla y introducirlos en un array | |
| 2. Mostrar el array completo (Todos sus elementos) | |
| 3. Ordenarlo | |
| 4. Invertir su orden y Mostrar | |
| 5. Mostrar cuantos elementos tiene | |
| 6. Buscar un valor introducido por el usuario que nos diga si lo encuentra y su indice. | |
| */ |
This file contains hidden or 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
| // DOM - DOCUMENT OBJECT MODEL | |
| // Selecionar un div segun su ID(#) o class(.) | |
| var caja = document.querySelector('#micaja'); | |
| // Seleccionar solo lo que contiene ese div | |
| caja.innerHTML; | |
| // Cambiar texto del div seleccionado (Antes el texto era (Soy una Caja) ) Ahora cambiara a |