+ 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

29th Jan 2024, 11:54 PM
Dr Melchisedec Bankole
Dr Melchisedec Bankole - avatar
9 odpowiedzi
+ 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.
30th Jan 2024, 2:51 AM
Bob_Li
Bob_Li - avatar
+ 1
Thanks, I will use the textarea option.💰💰🔥
30th Jan 2024, 4:55 AM
Dr Melchisedec Bankole
Dr Melchisedec Bankole - avatar
+ 1
maybe you have to provide the correct answer to compare to?
30th Jan 2024, 4:29 PM
Bob_Li
Bob_Li - avatar
+ 1
I have done that already.
30th Jan 2024, 8:48 PM
Dr Melchisedec Bankole
Dr Melchisedec Bankole - avatar
0
There is a new issue now "Error: expectedOutput is not defined Line: 148 Uncaught ReferenceError: expectedOutput is not defined Line: 151"
30th Jan 2024, 2:43 PM
Dr Melchisedec Bankole
Dr Melchisedec Bankole - avatar
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
30th Jan 2024, 10:49 PM
Bob_Li
Bob_Li - avatar
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.
30th Jan 2024, 11:14 PM
Dr Melchisedec Bankole
Dr Melchisedec Bankole - avatar
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?
30th Jan 2024, 11:29 PM
Bob_Li
Bob_Li - avatar
0
Idk
31st Jan 2024, 3:03 PM
Kripansh Baghel
Kripansh Baghel - avatar