Pages

🪛 coding !

 

JS : exercice


Evaluez le code suivant : 

const action = function (tab) {

  let i = 0
    , j = tab.length - 1;
  while (i < j) {
    if (tab[i] <= 0) {
      i++
    }
    else {
      let tmp = tab[i];
      tab[i] = tab[j];
      tab[j] = tmp;
      j--
    }
  }

  return tab
}
const surprise = action([-1, 1, -2, 10, 3])



Réponse : for (let i = 0; i< texte.length ; i++) {