mardi 28 avril 2020

Loop before launching function

I would like to run a function with different parameters each time. But instead of looping on each fruit and launch the function it will just loop all fruits AND run the function without parameters.

export async function runTestForAll() {
  var fruits = require('./fruits.json');
  var fruitsArray = Object.keys(fruits);
  var arrayLength = fruitsArray.length;    

  for (var i = 0; i < arrayLength; i++) {
    console.log(fruitsArray[i])
    fruits = fruitArray[i]
    runTest(fruits)
  }
};

Aucun commentaire:

Enregistrer un commentaire