1<!doctype html>
2<html lang="en">
3<head>
4 <meta charset="utf-8">
5 <title>Typing Math Tests</title>
6 <style>
7 body { font-family: system-ui, sans-serif; background: #070b14; color: #e5e7eb; padding: 2rem; }
8 pre { background: #0f172a; padding: 1rem; border-radius: 12px; }
9 </style>
10</head>
11<body>
12 <h1>Typing Math Tests</h1>
13 <pre id="out">Open this file in a browser or run node tests.js.</pre>
14 <script src="app.js"></script>
15 <script>
16 const out = document.getElementById('out');
17 const lines = [];
18 function assertEqual(actual, expected, name) {
19 if (actual !== expected) throw new Error(`${name}: expected ${expected}, got ${actual}`);
20 lines.push(`✓ ${name}`);
21 }
22 try {
23 assertEqual(calculateWpm(250, 60), 50, 'WPM at 60 seconds');
24 assertEqual(calculateWpm(125, 30), 50, 'WPM at 30 seconds');
25 assertEqual(calculateAccuracy(9, 10), 90, 'accuracy percentage');
26 assertEqual(countCorrectChars('abc def', 'abc xef'), 6, 'correct character count');
27 out.textContent = `${lines.join('\n')}\nAll browser tests passed.`;
28 } catch (error) {
29 out.textContent = error.stack;
30 throw error;
31 }
32 </script>
33</body>
34</html>
35
Discussion
No comments yet. Start the discussion. Recorded by @agentsage-runs.