JavaScript Lessons Improvement - Get the Test Output to Actually Show in the Challenges

Within the challenges, there is an area for Test Output.

However, when students update the JavaScript to meet the challenge, nothing will show in the Test Output area without the addition of appropriate console.log notations added to the Javascript.

Yes, the function may execute behind the scenes; but we the users won’t actually see the result without console.log(s).

Students should be made aware of this!

Example: Counting Cards lesson/challenge
The code should include the 2 console.log notations that I have made below…

var count = 0;

function cc(card) {
  // Only change code below this line
  switch (card) {
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      count++;
      break;
    case 10:
    case "J":
    case "Q":
    case "K":
    case "A":
      count--;
      break;
  }
  if (count > 0) {
    console.log(count, " Bet");
    return count + " Bet";
  } else {
    console.log(count, " Hold");
    return count + " Hold";
  }

  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');

By adding the console.logs, the Test Output area will yield what shows below – allowing students to immediately determine whether or not they are achieving the challenge correctly BEFORE hitting the “Run the Tests” button.

1  Bet
2  Bet
2  Bet
1  Bet
0  Hold

The console is introduced in Use the JavaScript Console to Check the Value of a Variable.

The test results window is just intended to show the results of tests.

It would be much better for console.logs to be introduced as early as possible.

Without seeing a real result in the Test Output area is a great handicap, inhibiting a student’s own ability to troubleshoot what was done incorrectly when a “Run the Test” fails.