window.common = (function(global) {
  const {
    CodeMirror,
    document: doc,
    common = { init: [] }
  } = global;

  const { challengeTypes, challengeType = '0' } = common;

  if (
    !CodeMirror ||
    challengeType !== challengeTypes.JS &&
    challengeType !== challengeTypes.BONFIRE
  ) {
    common.updateOutputDisplay = () => {};
    common.appendToOutputDisplay = () => {};
    return common;
  }

  var codeOutput = CodeMirror.fromTextArea(
    doc.getElementById('codeOutput'),
    {
      lineNumbers: false,
      mode: 'text',
      theme: 'monokai',
      readOnly: 'nocursor',
      lineWrapping: true
    }
  );

  codeOutput.setValue(`/**
  * Your output will go here.
  * Console.log() -type statements
  * will appear in your browser\'s
  * DevTools JavaScript console.
  */`);

  codeOutput.setSize('100%', '100%');

  common.updateOutputDisplay = function updateOutputDisplay(str = '') {
    str = JSON.stringify(str);
    codeOutput.setValue(str);
    return str;
  };

  common.appendToOutputDisplay = function appendToOutputDisplay(str = '') {
    str = JSON.stringify(str);
    codeOutput.setValue(codeOutput.getValue() + str);
    return str;
  };

  return common;
}(window));

@@ -901,32 +901,69 @@
 lay(str = '') %7B%0A
+    if (typeof str !== 'string') %7B%0A  
     str = JSON.s
@@ -969,32 +969,38 @@
 stringify(str);%0A
+    %7D%0A
     codeOutput.s
@@ -1115,39 +1115,8 @@
 ) %7B%0A
-    str = JSON.stringify(str);%0A
     

Prettify the code execution output