kaselokOgrulari.js

    0

    0

    [1, 10, 4, 2, 3]

    function qilmanCocuklar(kaslok) {
      let greatest = kaslok.sort((a, b) => a - b).reverse();
      greatest = greatest[0];
    
      kaslok.forEach((item, index) => {
        if (item === greatest) {
          kaslok.splice(index, 1);
        }
      });
    
      for (let i = 0; i < kaslok.length; i++) {
        for (let j = 0; j < kaslok.length; j++) {
          if (kaslok[i] + kaslok[j] === greatest) {
            kaslok.splice(kaslok.indexOf(kaslok[i]), 1);
            kaslok.splice(kaslok.indexOf(kaslok[j]), 1);
            greatest += kaslok.reduce((a, b) => a + b);
          }
        }
      }
    
      console.log(greatest, kaslok);
    }
    
    qilmanCocuklar([4, 2, 3, 1, 10]);
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.