forked from b00tc4mp/isdi-parttime-202410
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
87 additions
and
10 deletions.
There are no files selected for viewing
51 changes: 43 additions & 8 deletions
51
staff/quique-cabrera/playground/array/Array.prototype.concat.test.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 |
---|---|---|
@@ -1,19 +1,54 @@ | ||
console.log('TEST Array.prototype.concat') | ||
|
||
console.log('CASE merge two arrays') | ||
|
||
var sea = new Array | ||
sea[0] = 'shark' | ||
sea[1] = 'octopus' | ||
sea[2] = 'Sponge' | ||
sea[3] = 'Whale' | ||
console.log(sea) | ||
//[ 'shark', 'octopus', 'Sponge', 'Whale' ] | ||
console.log(sea.length) | ||
4 | ||
|
||
var land = new Array | ||
land[0] = 'elephant' | ||
land[1] = 'bear' | ||
land[2] = 'fox' | ||
land[3] = 'lion' | ||
console.log(land) | ||
//[ 'elephant', 'bear', 'fox', 'lion' ] | ||
console.log(land.length) | ||
//4 | ||
|
||
var forest = new Array | ||
forest[0] = 'elephant' | ||
forest[1] = 'bear' | ||
forest[2] = 'fox' | ||
forest[3] = 'lion' | ||
var sky = new Array | ||
sky[0] = 'crow' | ||
sky[1] = 'eagle' | ||
sky[2] = 'sparow' | ||
sky[3] = 'duck' | ||
console.log(sky) | ||
//[ 'crow', 'eagle', 'sparow', 'duck' ] | ||
console.log(sky.length) | ||
//4 | ||
|
||
var animals = sea.concat(forest); | ||
console.log('CASE 1 merge two animals class') | ||
|
||
var animals = sea.concat(land); | ||
console.log(animals) | ||
//[ 'shark', 'octopus', 'Sponge', 'Whale', 'elephant', 'bear', 'fox', 'lion' ] | ||
console.log(animals.length) | ||
//8 | ||
|
||
console.log('CASE 2 merge three animals class') | ||
|
||
var wildLife = sea.concat(land, sky) | ||
console.log(wildLife) | ||
//['shark', 'octopus', 'Sponge', 'Whale', 'elephant', 'bear', 'fox', 'lion', 'crow', 'eagle', 'sparow', 'duck'] | ||
console.log(wildLife.length) | ||
//12 | ||
|
||
console.log('CASE 3 merge three animals class and string') | ||
var party = sea.concat(land, sky, ' are going to party!') | ||
console.log(party) | ||
//['shark', 'octopus', 'Sponge', 'Whale', 'elephant', 'bear', 'fox', 'lion', 'crow', 'eagle', 'sparow', 'duck', ' are going to party!'] | ||
console.log(party.length) | ||
//13 |
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
8 changes: 8 additions & 0 deletions
8
staff/quique-cabrera/playground/array/Array.prototype.lastIndexOf.test.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,8 @@ | ||
console.log('TEST Array.prototype.lastIndexOf') | ||
|
||
console.log('CASE 1 returns the index of second groundhog') | ||
|
||
var frase = 'The goose saw the groundhog, but the groundhog went away' | ||
|
||
console.log(frase.lastIndexOf('groundhog')) | ||
//37 |
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
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,19 @@ | ||
console.log('TEST Array.prototype.reverse') | ||
|
||
console.log('CASE reverse array order') | ||
|
||
var elements = new Array | ||
elements[0] = 'H2O' | ||
elements[1] = 'CO2' | ||
elements[2] = 'NO2' | ||
elements[3] = 'CU2S' | ||
|
||
console.log('elements:', elements) | ||
//elements: [ 'H2O', 'CO2', 'NO2', 'CU2S' ] | ||
|
||
var newOrder = elements.reverse() | ||
console.log('New Order', newOrder) | ||
//New Order [ 'CU2S', 'NO2', 'CO2', 'H2O' ] | ||
|
||
console.log('elements:', elements) | ||
//New Order [ 'CU2S', 'NO2', 'CO2', 'H2O' ] |
12 changes: 12 additions & 0 deletions
12
staff/quique-cabrera/playground/dorraymon/Dorraymon.prototype.concat.test.1.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,12 @@ | ||
function Dorraymon() { | ||
this.length = 0 | ||
} | ||
|
||
Dorraymon.prototype.concat = function (element) { | ||
for (var i = 0; i < this.length; i++) { | ||
result = this[i] | ||
result.length++ | ||
} | ||
|
||
return this.length | ||
} |
Empty file.
Empty file.
Empty file.