Skip to content

Commit

Permalink
update branch b00tc4mp#167
Browse files Browse the repository at this point in the history
  • Loading branch information
carlos committed Sep 1, 2024
1 parent ca08c1f commit 9eca66b
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 10 deletions.
10 changes: 5 additions & 5 deletions staff/carlos-bock/chain-characters/concat.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
// convertir numero en string
// si el valor el null el resultado es string de null

const ChainCharacters = require("./constructor")

function concat(...strings) {
let result = this.value;

let str = '';
for (let i = 0; i < strings.length; i++) {
str += strings[i];
result += strings[i];
}
return str;
return new ChainCharacters(result);
}

module.exports = concat



10 changes: 5 additions & 5 deletions staff/carlos-bock/chain-characters/concat.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ const string4 = "1";
const string5 = "2";
const string6 = "3";

const result1 = new ChainCharacters(string1,string2,string3).concat();
console.assert(result1 === string1.concat(string2,string3),{
const result1 = new ChainCharacters(string1).concat(string2,string3);
console.assert(result1.value === string1.concat(string2,string3),{
result: result1,
message: "Test 1 No pasado ",
});

const result2 = new ChainCharacters(string4,string5,string6).concat();
console.assert(result2 === string4.concat(string5,string6),{
console.log(result1);
const result2 = new ChainCharacters(string4).concat(string5,string6);
console.assert(result2.value === string4.concat(string5,string6),{
result: result2,
message: "Test 1 No pasado ",
});
48 changes: 48 additions & 0 deletions staff/carlos-bock/challenge-array/for-each.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//crear función que aplica otra función a todos los valores del array
//crear función simple de prueba
const array=["Los", "gatos", "son", "guay"];
const result= [];

function forEach(array, callBackFunction){
//haz algo
}


/////////////////////////////////////////////////////////////


function test(element){
//result[result.length]= element
if (element.length>3){
result[result.length] = element;
}
}

///////////////////////////////////////////////////////////

{
function arrayIsEqual(arr1, arr2) {
if (arr1.length !== arr2.length) return false;
let result = true;
let i = 0;
while (i < arr1.length || result === false) {
if (arr1[i] !== arr2[i]) {
result = false;
}
i++;
}
return result;
}
/////////////////////////////////////////////////////////////////
const array1 = [1, 2, 3, 4, 5, 6, 7, 8];
const result1 = splice(array1, 4);

console.assert(arrayIsEqual(array1, [1, 2, 3, 4]), {
result: array1,
message: "Test 1.1 no pasado",
});
console.assert(arrayIsEqual(result1, [5, 6, 7, 8]), {
result: result1,
message: "Test 1.2 no pasado",
});
}

0 comments on commit 9eca66b

Please sign in to comment.