Ad
Code
Diff
  • function numMinusSeven(num) {
      if(num <= 0) return 0;
      return numMinusSeven(num-7) + 1;
    }
    
    • function numMinusSeven(num) {
    • let aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = []
    • while (num > 0) {
    • num -= 7
    • aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.push(num)
    • }
    • return aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.length
    • if(num <= 0) return 0;
    • return numMinusSeven(num-7) + 1;
    • }
Code
Diff
  • const addArr = (arr) => arr.reduce((a, b) => a + b, null)
    
    • const addArr = (arr) => {
    • let sum = 0;
    • for (let i = 0; i < arr.length; i++) {
    • sum += arr[i];
    • }
    • return sum || null;
    • };
    • const addArr = (arr) => arr.reduce((a, b) => a + b, null)
Code
Diff
  • const piramidos = (num) => {
      if(num <= 0) return ''
      return piramidos(num-1) + '\n' + 'x'.repeat(num*2-1);
    }
    
    //console.log(piramidos(5))
    • function piramids(numero){
    • var pisos = [];
    • var espacio = " ";
    • var caracter = "x";
    • var coespacios = numero - 1;
    • for(let i = 0; i < numero; i++){
    • pisos[i]="";
    • var cocaracter = ((i + 1)*2)-1;
    • for(let e = 0; e < coespacios; e++){
    • pisos[i] += espacio;
    • }
    • for(let c = 0; c < cocaracter; c++){
    • pisos[i] += caracter;
    • }
    • coespacios --;
    • }
    • for(let f = 0; f < numero; f++){
    • console.log(pisos[f]);
    • }
    • const piramidos = (num) => {
    • if(num <= 0) return ''
    • return piramidos(num-1) + '\n' + 'x'.repeat(num*2-1);
    • }
    • piramids(5);
    • /*var parte = "que";
    • var parte2 = "so";
    • const unir = parte + parte2;
    • console.log(unir);*/
    • //console.log(piramidos(5))