Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
text for JavaScript lesson class.
<form id="input">
<textarea id="list" rows="20" cols="30"></textarea>
<input type="button" value="run" onclick="quoteNumbers()">
<pre id="result">
<script type="text/javascript"><!--
function quoteNumbers() {
numbers = getList();
comma_nums = makeQueryParameter(numbers);
function getList() {
return document.getElementById("list").value;
function showResult(result) {
document.getElementById("result").innerHTML = result;
String.prototype.eachRows = function() { return this.split(/\s/); }
function makeQueryParameter(list) {
reject_empty_row = function(row) {return row != '';};
surround_by_quote = function(item) { return "'" + item.toString() + "'"; };
return list.eachRows().filter(reject_empty_row).map(surround_by_quote).join(",\n");
// --></script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.