Is it possible to have multiple scans in one line?


#1

Instead of typing:

cashRegister.scan("item");
cashRegister.scan("item1");
cashRegister.scan("item2");
cashRegister.scan("item3");
cashRegister.scan("item4");

is there a way to pass multiple parameters in series, like:

cashRegister.scan("item1", "item2", "item3", "item4");

or something similar? This seems strangely inefficient.

Thanks!


#2

Ok, the next lesson has a workaround, but my original question still stands... :expressionless:


#3

Give it an array or let your function handle an arbitrary number of arguments

function f() {
  for (var i = 0; i < arguments.length; ++i) {
    console.log(arguments[i]);
  }
}


f(3, 5, 6);