Don't stringify answer if already a string

This commit is contained in:
Alain Bryden 2022-08-24 11:09:35 -03:00 committed by GitHub
parent 839703090b
commit 359def2b61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -37,7 +37,7 @@ export function NetscriptCodingContract(): InternalAPI<ICodingContract> {
throw new Error("The answer provided was not a number, string, or array");
// Convert answer to string.
const answerStr = JSON.stringify(answer);
const answerStr = typeof answer === 'string' ? answer : JSON.stringify(answer);
const creward = contract.reward;
if (creward === null) throw new Error("Somehow solved a contract that didn't have a reward");