Skip to content

Instantly share code, notes, and snippets.

@avovsya
Created February 17, 2017 11:23
Show Gist options
  • Save avovsya/82e8a741ce2d7ce82f656f44a7f66f05 to your computer and use it in GitHub Desktop.
Save avovsya/82e8a741ce2d7ce82f656f44a7f66f05 to your computer and use it in GitHub Desktop.
function readAllNumbers(input) {
var number = "";
var numbers = [];
for (var i = 0; i < input.length; i++) {
if (input[i] === ' ' || input[i] === '\n') {
numbers.push(parseInt(number));
number = "";
continue;
} else {
number += input[i];
}
}
numbers.push(parseInt(number));
return numbers;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment