Feedback on: irt.org FAQ Knowledge Base Q585
Worth:
Worth reading
Comments:
1. If you enter only one line and hit "Refresh", split by "\n" does not create an array but returns the string itself, therefore textArray.length has the length of the string instead of 1.
2. If you enter less than 10 rows (the default value), testing textArray[i].length with i from 0 to rows gets you an error.
Therefore you need to modify the lines:
var textArray = text.split('\n');
if (textArray.length > rows)
rows = textArray.length;
for (var i=0; i<rows; i++)
if (textArray[i].length > cols)
cols = textArray[i].length;
with:
var textArray;
if (text.indexOf('\n') != -1) {
textArray = text.split('\n');
} else {
textArray = new Array(text);
}
if (textArray.length > rows)
rows = textArray.length;
for (var i=0; i<rows; i++) Worth: Comments: Example: I wrote See ya.
if (i
Worth reading
Also, in the confirmation page for this feedback (after pressing Submit Feedback) you interpreted some HTML special characters I wrote. You may want to escape them, as I was very close to submit it again.
if (i<textArray.length && textArray[i].length>cols)
and all text between the < and the > dissapeared.