this script does nothing

G

greenflame

I have the following script but it does not show anything. It works of
I take away the squareroot function. I dont see what is wrong.

function show(input) {
if (input.length == 1) {
for (i=0;i<input[0].length;i++) {
document.write(convert(input[0]));
}
document.write("<br>");
} else {
for (i=0;i<input.length;i++) {
for (j=0;j<input[0].length;j++) {
document.write(convert(input[j]));
}
document.write("<br>");
}
}
}
function squareroot(input) {
output = copy2darr(input);
top = new Array(output[0].length);
for (var i=0;i<output[0].length;i++) {
top = "&#151";
}
n = output.unshift(top);
for (var i=0;i<output.length;i++) {
if (i == 0) {
n = output.unshift("┌");
} else {
n = output.unshift("│");
}
}
for (var i=0;i<output.length;i++) {
if (i != output.length-1) {
n = output.unshift(" ");
} else {
n = output.unshift("\"); // It says there is an
unterminated string constant here.
}
}
return output;
}
document.write("long hyphen: —<br>leftmost peice:
┌<br>rightmost peice: ┐<br>taller bar: │<br>square
root symbol: √<br><br>");
arr = [
[" ","5"," "," "," "," "],
["x"," "," ","+"," ","x"]];
show(arr);
 
L

Lasse Reichstein Nielsen

greenflame said:
I have the following script but it does not show anything. It works of
I take away the squareroot function. I dont see what is wrong.

This would be a good place to say what the error message is, instead
of hiding it in the code as a comment :)
n = output.unshift("\"); // It says there is an
unterminated string constant here.


That's because there is. Inside a string literal, the backslash
is used to escape the following character. To write a string
containing a quote, you can write:
"This \" is a quote".

What you write is "\", which begins a string literal starting with a
quote character. To have backslashes inside a string, they too must
be escaped, so change it to: "\\".


Good luck.
/L
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top