Code Highlights Lesson

Code highlights draw attention to the part of an example that matters most. A snippet often contains setup code, but the lesson usually depends on one line, one method, or one pattern.
Highlighting helps the reader know where to focus. Instead of treating every line as equally important, the lesson can explain which part demonstrates the concept.

Code Runner Challenge

Code Highlights Lesson

View IPYNB Source
%%js

// CODE_RUNNER: Code Highlights Lesson

const prices = [8, 12, 5];

const total = prices.reduce(function(sum, price) {
  return sum + price;
}, 0);

console.log("Total: " + total);
Lines: 1 Characters: 0
Output
Click "Run" in code control panel to see output ...

The important line is the return statement inside reduce. It shows how each price is added into the running sum.