fork download
  1.  
  2.  
  3. // your code goes here
  4. let tokens = ["a", "a", "to", "b", "c"];
  5. let pos = tokens.findIndex(e => (e === "to"));
  6. print(pos);
  7. let lists = [];
  8. if (pos >= 0) {
  9. pos++;
  10. while (pos < tokens.length() && tokens[pos].search("@") === 0) {
  11. print(pos);
  12. lists.push(tokens[pos]);
  13. }
  14. }
  15. print(lists);
  16. if (lists.length() === 0) {
  17. lists.push("@default");
  18. } else {
  19. tokens.splice(pos - lists.length() - 1, pos);
  20. }
Runtime error #stdin #stdout #stderr 0s 171392KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
prog.js:5:0 TypeError: tokens.findIndex is not a function