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 | |
| const element = ["purple", 1, 3 + 5, "juan" + 4, function saludar(){console.log("holi")}, ["Lunes", "Martes", "Miercoles"], [1, 2, 3, 4,[0, "3er level"]]]; | |
| console.log(element); | |
| console.log(element[4]); | |
| element[4](); | |
| console.log(element[5][2]); | |
| console.log(element[6][4][1]); |
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 | |
| const colors = ["purple", "yellow", "red", "white", "black"]; | |
| //console.log(colors[1]); | |
| //console.log(colors.indexOf("yellow")); | |
| //console.log(colors.indexOf("pink")); | |
| // function to erase element | |
| function eraseElementArray(element, array) { | |
| const result = array.indexOf(element); |
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 | |
| const days = [ | |
| "Lunes", | |
| "Martes", | |
| "Miercoles", | |
| "Jueves", | |
| "Viernes", | |
| "Sabado", | |
| "domingo" | |
| ] |
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
| // Normal | |
| const brand1 = "Ford", | |
| brand2 = "Seat", | |
| brand3 = "Mercedes", | |
| brand4 = "Porsch", | |
| brand5 = "BMW"; | |
| // Arrays | |
| // Save information with a relationship | |
| const autoBrands = [ |
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
| // Working with forEach | |
| const numbers = [1, 2, 3, 4, 5]; | |
| var total = 0; | |
| numbers.forEach(function (number) { | |
| total += number; | |
| }); | |
| console.log('Working with forEach: ' + total); | |
| // Working with reduce | |
| var total_reduce = [1, 2, 3, 4, 5].reduce(function (accumulator, current, index) { |
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
| const colors = [ | |
| { | |
| color: "red", | |
| value: "#f00" | |
| }, | |
| { | |
| color: "yellow", | |
| value: "#0f0" | |
| }, | |
| { |
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
| const colors = [ | |
| { | |
| color: "red", | |
| value: "#f00" | |
| }, | |
| { | |
| color: "green", | |
| value: "#0f0" | |
| }, | |
| { |
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
| const createNote = text => ({ | |
| text: text, | |
| createdAt: new Date(), | |
| completed: false, | |
| toString: function (){ | |
| return noteToString(this); | |
| } | |
| }); // debes implementar esta función ;-) | |
| const noteToString = note => [ |
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
| function Note(text) { | |
| this.text = text || ''; | |
| this.createdAt = new Date(); | |
| this.completed = false; | |
| } | |
| // [X] | Mon Jun 12 2017 | mundo | |
| Note.prototype.toString = function () { | |
| let str = '[' + (this.completed ? 'X' : ' ') + ']'; | |
| str += ' | ' + this.createdAt.toDateString(); | |
| str += ' | ' + this.text; |
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
| function isPrime(num) { | |
| var isPrime = true; | |
| for (var i = 2; i <= num/2; i++){ | |
| if (num % i === 0) { | |
| isPrime = false; | |
| } | |
| } | |
| return isPrime; | |
| } |
NewerOlder