Code
Output
Run
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
// JavaScript runs right here in your browser. // Anything you console.log appears in the Console panel below. const names = ["Aline", "Eric", "Chantal"]; function greet(name) { return `Muraho, ${name}!`; } for (const name of names) { console.log(greet(name)); } const marks = [82, 74, 91, 68]; const average = marks.reduce((a, b) => a + b, 0) / marks.length; console.log("average:", average.toFixed(1)); // Whatever you put on the page shows in the preview: document.getElementById("root").innerHTML = "<h2 style='font-family:system-ui'>" + greet("Rwanda") + "</h2>";
Output
Loading runtime…
Ready when you are
Edit the code, then press Run (or ⌘/Ctrl+Enter) to see it here.
Console
Console output appears here…