Last active
May 23, 2022 00:04
Revisions
-
anibal21 revised this gist
May 23, 2022 . 1 changed file with 6 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -32,6 +32,12 @@ let yearTemperature = [40, 44, 40, 34, 30, 28, 26, 25, 28, 39, 35, 38] console.log(yearTemperature.some((temp) => temp > 40)) // There is at least one element over 40 degrees console.log(yearTemperature.every((temp) => temp % 2)) // false - not every number is mod 2 // Find and FindIndex let yearTemperature = [40, 44, 40, 34, 30, 28, 26, 25, 28, 39, 35, 38] console.log(yearTemperature.find((temp) => temp === 40)) // 40 the first value console.log(yearTemperature.findIndex((temp) => temp === 40)) // 0 the first encountered -
anibal21 revised this gist
May 23, 2022 . 1 changed file with 11 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -25,4 +25,14 @@ let arrayFrom = Array.from(literalArray) // copy of [1,2,3] // Creating and Updating at the same time let rankings = [0, 100, 40, 20, 40, 343, 32, 22] let copy = Array.from(rankings, (r) => r % 10 === 0 ? r : 0) console.log(copy) // [0, 100, 40, 20, 40, 0, 0, 0] // Some and Every let yearTemperature = [40, 44, 40, 34, 30, 28, 26, 25, 28, 39, 35, 38] console.log(yearTemperature.some((temp) => temp > 40)) // There is at least one element over 40 degrees console.log(yearTemperature.every((temp) => temp % 2)) // false - not every number is mod 2 /* End*/ -
anibal21 revised this gist
May 22, 2022 . 1 changed file with 5 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -21,3 +21,8 @@ let spreadOperatorArrays = [...literalArray] // copy of [1,2,3] let arrayConstructor = new Array() let arrayOf = Array.of(1,2,3) // [1,2,3] let arrayFrom = Array.from(literalArray) // copy of [1,2,3] // Creating and Updating at the same time let rankings = [0, 100, 40, 20, 40, 343, 32, 22] let copy = Array.from(rankings, (r) => r % 10 === 0 ? r : 0) console.log(copy) // [0, 100, 40, 20, 40, 0, 0, 0] -
anibal21 revised this gist
May 22, 2022 . 1 changed file with 9 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ /** * Theory: -Arrays in JavaScript are an ordered collection of values -Its elements are untyped, an array can contain different types of data -Arrays are 32-bit indexed so its index can be from 0-4294967294 (2^32 - 2) and its elements can go from 0 to 4.294.967.295 @@ -13,4 +13,11 @@ let names = ["Anibal", "Peter"] console.log(names.length) // 2 names[10] = "Lucas" console.log(names.length) // 11 //Creating arrays let literalArray = [1,2,3] let spreadOperatorArrays = [...literalArray] // copy of [1,2,3] let arrayConstructor = new Array() let arrayOf = Array.of(1,2,3) // [1,2,3] let arrayFrom = Array.from(literalArray) // copy of [1,2,3] -
anibal21 created this gist
May 22, 2022 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ /** * Theory: -JavaScript are unordered -Its elements are untyped, an array can contain different types of data -Arrays are 32-bit indexed so its index can be from 0-4294967294 (2^32 - 2) and its elements can go from 0 to 4.294.967.295 */ /** * Relevant Examples */ // Dynamic Sizing let names = ["Anibal", "Peter"] console.log(names.length) // 2 names[10] = "Lucas" console.log(names.length) // 11