+ 1
Code now displays error after printing expected output. Why?
Error: expectedOutput is not defined Line: 148 Uncaught ReferenceError: expectedOutput is not defined Line: 151 https://sololearn.com/compiler-playground/WJsrB85zq7an/?ref=app
9 Answers
+ 4
Sololearn have a character limit in the input box.
You can use a textarea input instead.
you also don't have to use alert messages, too. Just display it as normal html paragraphs.
+ 1
Thanks, I will use the textarea option.đ°đ°đ„
+ 1
maybe you have to provide the correct answer to compare to?
+ 1
I have done that already.
0
There is a new issue now
"Error: expectedOutput is not defined
Line: 148
Uncaught ReferenceError: expectedOutput is not defined
Line: 151"
0
Dr Melchisedec Bankole
I looked over your code.
you did not define
expectedOutput
you defined
expectedOutputForLoop
expectedOutputSwitch
also, you did not push the evaluatedResult to the sandbox.output.
finally, after correcting the sandbox.output issue, maybe the check should be
return sandbox.output[0].join("\n")===expectedOutput.join("\n")
here is my modified version of your code. I commented out the copy-paste block so you can copy paste a sample solution I added at the end of the js code for testing.
One issue I find is that your check expects a very specific output format of a string array.
If the user used console.log, the check will fail. It also cannot handle function solutions.
https://sololearn.com/compiler-playground/Wlp4L465ZWh9/?ref=app
0
Thanks Bob.Li for your time.
Your effort to help is priceless to me.
However, the code you provided is also generating similar error message after printing the expected output.
What do you suggest please.
0
Dr Melchisedec Bankole
the checkCode expects a string array.
The same format as your expectedOutput.
That is why it is problematic. Because the usual way is to simply console.log the output. But this does not pass your check.
I modified your code to default with a working solution for testing.
can you post an example solution you used?
0
Idk