Run REPL
📦 Node.js-> Command Line
✨ The Prompt Phrase
node
💻 Code Preview
📦 All-in-One Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>⬢ Node.js & REPL Master Guide</title>
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700;800&family=Fira+Code:wght@400;500&display=swap" rel="stylesheet">
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
--node: #68a063;
--cyan: #06b6d4;
--purple: #8b5cf6;
--pink: #ec4899;
--orange: #f97316;
--yellow: #fbbf24;
--blue: #3b82f6;
--green: #10b981;
--red: #ef4444;
--bg: #0a0e1a;
--card: #151b2e;
--text: #e2e8f0;
}
body {
font-family: 'Poppins', sans-serif;
background: var(--bg);
color: var(--text);
min-height: 100vh;
overflow-x: hidden;
}
/* Animated background */
.bg-animation {
position: fixed;
inset: 0;
z-index: -1;
overflow: hidden;
}
.float-symbol {
position: absolute;
font-size: 3rem;
opacity: 0.08;
font-family: 'Fira Code', monospace;
animation: symbolFloat 20s infinite ease-in-out;
color: var(--node);
}
@keyframes symbolFloat {
0%, 100% { transform: translate(0, 0) rotate(0deg); }
25% { transform: translate(100px, -100px) rotate(90deg); }
50% { transform: translate(200px, 50px) rotate(180deg); }
75% { transform: translate(-50px, 150px) rotate(270deg); }
}
.orb {
position: absolute;
border-radius: 50%;
filter: blur(120px);
opacity: 0.15;
animation: orbMove 30s ease-in-out infinite;
}
@keyframes orbMove {
0%, 100% { transform: translate(0, 0) scale(1); }
50% { transform: translate(100px, -100px) scale(1.3); }
}
/* Progress bar */
.progress {
position: fixed;
top: 0;
left: 0;
height: 4px;
background: linear-gradient(90deg, var(--node), var(--cyan), var(--purple), var(--pink));
z-index: 1000;
transition: width 0.2s;
}
/* Header */
header {
text-align: center;
padding: 70px 20px 50px;
position: relative;
}
.logo-container {
display: flex;
justify-content: center;
align-items: center;
gap: 25px;
margin-bottom: 35px;
flex-wrap: wrap;
}
.node-logo {
width: 110px;
height: 110px;
background: linear-gradient(135deg, var(--node), var(--green));
border-radius: 24px;
display: flex;
align-items: center;
justify-content: center;
font-size: 3.5rem;
cursor: pointer;
transition: all 0.3s;
box-shadow: 0 20px 60px rgba(104, 160, 99, 0.4);
animation: logoFloat 4s ease-in-out infinite;
position: relative;
overflow: hidden;
}
@keyframes logoFloat {
0%, 100% { transform: translateY(0) rotate(0deg); }
50% { transform: translateY(-20px) rotate(5deg); }
}
.node-logo::before {
content: '';
position: absolute;
inset: 0;
background: linear-gradient(45deg, transparent, rgba(255,255,255,0.3), transparent);
animation: logoShine 3s infinite;
}
@keyframes logoShine {
0% { transform: translateX(-100%) rotate(45deg); }
100% { transform: translateX(200%) rotate(45deg); }
}
.node-logo:hover {
transform: scale(1.15) rotate(10deg);
box-shadow: 0 30px 80px rgba(104, 160, 99, 0.6);
}
.repl-demo {
background: rgba(6, 182, 212, 0.1);
border: 2px solid var(--cyan);
border-radius: 14px;
padding: 15px 25px;
font-family: 'Fira Code', monospace;
font-size: 0.9rem;
animation: replPulse 3s ease-in-out infinite;
}
@keyframes replPulse {
0%, 100% { transform: scale(1); box-shadow: 0 0 20px rgba(6, 182, 212, 0.3); }
50% { transform: scale(1.05); box-shadow: 0 0 40px rgba(6, 182, 212, 0.5); }
}
h1 {
font-size: clamp(2rem, 6vw, 3.5rem);
font-weight: 800;
background: linear-gradient(135deg, var(--node), var(--cyan), var(--purple));
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
margin-bottom: 18px;
line-height: 1.2;
}
.subtitle {
color: #64748b;
font-size: 1.2rem;
max-width: 700px;
margin: 0 auto;
}
/* Main container */
main {
max-width: 1100px;
margin: 0 auto;
padding: 20px;
}
.section {
margin-bottom: 55px;
opacity: 0;
transform: translateY(50px);
transition: all 0.8s ease-out;
}
.section.vis {
opacity: 1;
transform: translateY(0);
}
.sec-title {
display: flex;
align-items: center;
gap: 18px;
font-size: 1.7rem;
font-weight: 700;
margin-bottom: 22px;
}
.sec-icon {
width: 56px;
height: 56px;
border-radius: 16px;
display: flex;
align-items: center;
justify-content: center;
font-size: 1.6rem;
animation: iconWobble 3s ease-in-out infinite;
}
@keyframes iconWobble {
0%, 100% { transform: rotate(-5deg) scale(1); }
50% { transform: rotate(5deg) scale(1.1); }
}
/* Cards */
.card {
background: var(--card);
border-radius: 22px;
padding: 32px;
margin-bottom: 24px;
border: 1px solid rgba(255,255,255,0.08);
transition: all 0.3s;
position: relative;
overflow: hidden;
}
.card::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
height: 5px;
background: linear-gradient(90deg, var(--node), var(--cyan), var(--purple));
}
.card:hover {
transform: translateY(-8px);
box-shadow: 0 30px 70px rgba(0,0,0,0.4);
border-color: var(--cyan);
}
.card h3 {
color: var(--cyan);
margin-bottom: 18px;
font-size: 1.4rem;
display: flex;
align-items: center;
gap: 12px;
}
.card p {
color: #94a3b8;
line-height: 1.9;
margin-bottom: 16px;
}
/* Featured card */
.featured {
background: linear-gradient(135deg, rgba(104, 160, 99, 0.15), rgba(6, 182, 212, 0.15));
border: 2px solid var(--node);
}
.featured-badge {
position: absolute;
top: -14px;
right: 30px;
background: linear-gradient(135deg, var(--orange), var(--yellow));
color: #000;
padding: 7px 20px;
border-radius: 22px;
font-size: 0.75rem;
font-weight: 700;
animation: badgePulse 2s ease-in-out infinite;
}
@keyframes badgePulse {
0%, 100% { box-shadow: 0 0 20px rgba(249, 115, 22, 0.5); }
50% { box-shadow: 0 0 40px rgba(249, 115, 22, 0.8); }
}
/* Code blocks */
.code-block {
background: #0a0f1a;
border-radius: 18px;
overflow: hidden;
margin: 22px 0;
border: 1px solid rgba(255,255,255,0.08);
box-shadow: 0 15px 45px rgba(0,0,0,0.4);
}
.code-header {
background: rgba(0,0,0,0.4);
padding: 16px 22px;
display: flex;
align-items: center;
justify-content: space-between;
}
.code-dots {
display: flex;
gap: 8px;
}
.dot {
width: 13px;
height: 13px;
border-radius: 50%;
cursor: pointer;
transition: all 0.2s;
}
.dot:hover { transform: scale(1.4); }
.dot.r { background: #ff5f56; }
.dot.y { background: #ffbd2e; }
.dot.g { background: #27ca40; }
.code-lang {
color: var(--cyan);
font-size: 0.9rem;
font-weight: 600;
font-family: 'Fira Code', monospace;
}
.code-copy {
background: rgba(255,255,255,0.1);
border: none;
padding: 8px 18px;
border-radius: 8px;
color: var(--text);
cursor: pointer;
font-size: 0.85rem;
transition: all 0.3s;
font-weight: 600;
}
.code-copy:hover {
background: var(--cyan);
transform: translateY(-2px);
color: #000;
}
.code-copy.copied { background: var(--green); }
.code-body {
padding: 24px;
font-family: 'Fira Code', monospace;
font-size: 0.9rem;
line-height: 2;
overflow-x: auto;
}
.kw { color: var(--purple); }
.str { color: var(--yellow); }
.num { color: var(--orange); }
.func { color: var(--cyan); }
.comment { color: #6b7280; font-style: italic; }
.var { color: var(--pink); }
.prop { color: var(--green); }
/* Interactive REPL */
.repl-container {
background: linear-gradient(135deg, rgba(6, 182, 212, 0.1), rgba(139, 92, 246, 0.1));
border-radius: 22px;
padding: 35px;
border: 2px solid rgba(6, 182, 212, 0.3);
margin: 28px 0;
}
.repl-title {
font-size: 1.5rem;
font-weight: 700;
color: var(--yellow);
margin-bottom: 22px;
text-align: center;
}
.terminal {
background: #0a0f1a;
border-radius: 16px;
overflow: hidden;
margin: 22px 0;
box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.term-header {
background: rgba(0,0,0,0.4);
padding: 14px 22px;
display: flex;
align-items: center;
gap: 10px;
}
.term-title {
flex: 1;
text-align: center;
color: #64748b;
font-size: 0.9rem;
font-weight: 600;
}
.term-body {
padding: 24px;
font-family: 'Fira Code', monospace;
font-size: 0.9rem;
min-height: 200px;
max-height: 500px;
overflow-y: auto;
}
.term-line {
margin-bottom: 10px;
animation: lineAppear 0.3s ease-out;
}
@keyframes lineAppear {
from { opacity: 0; transform: translateX(-10px); }
to { opacity: 1; transform: translateX(0); }
}
.prompt {
color: var(--node);
font-weight: 600;
text-shadow: 0 0 10px rgba(104, 160, 99, 0.5);
}
.cursor {
display: inline-block;
width: 10px;
height: 20px;
background: var(--cyan);
animation: blink 1s infinite;
vertical-align: middle;
margin-left: 2px;
}
@keyframes blink {
0%, 50% { opacity: 1; }
51%, 100% { opacity: 0; }
}
/* Command buttons */
.cmd-buttons {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 14px;
margin: 22px 0;
}
.cmd-btn {
background: var(--card);
padding: 18px;
border-radius: 14px;
border: 2px solid rgba(255,255,255,0.1);
cursor: pointer;
transition: all 0.3s;
text-align: center;
}
.cmd-btn:hover {
border-color: var(--cyan);
background: rgba(6, 182, 212, 0.1);
transform: translateY(-5px);
}
.cmd-btn-icon {
font-size: 2rem;
margin-bottom: 10px;
}
.cmd-btn-title {
color: var(--cyan);
font-weight: 600;
margin-bottom: 6px;
}
.cmd-btn-desc {
color: #64748b;
font-size: 0.85rem;
}
/* Steps */
.steps {
display: flex;
flex-direction: column;
gap: 18px;
}
.step {
display: flex;
gap: 20px;
padding: 24px;
background: rgba(255,255,255,0.02);
border-radius: 16px;
border: 1px solid rgba(255,255,255,0.06);
cursor: pointer;
transition: all 0.3s;
}
.step:hover {
transform: translateX(12px);
border-color: var(--node);
background: rgba(104, 160, 99, 0.1);
}
.step-num {
width: 48px;
height: 48px;
border-radius: 50%;
background: linear-gradient(135deg, var(--node), var(--cyan));
display: flex;
align-items: center;
justify-content: center;
font-weight: 800;
flex-shrink: 0;
font-size: 1.2rem;
box-shadow: 0 8px 25px rgba(104, 160, 99, 0.4);
}
.step-content h4 {
margin-bottom: 8px;
color: var(--text);
font-size: 1.1rem;
}
.step-content p {
color: #64748b;
font-size: 0.95rem;
margin: 0;
line-height: 1.6;
}
/* Info boxes */
.info {
padding: 22px;
border-radius: 16px;
margin: 20px 0;
display: flex;
gap: 16px;
align-items: flex-start;
}
.info.tip {
background: rgba(104, 160, 99, 0.12);
border-left: 4px solid var(--node);
}
.info.warn {
background: rgba(251, 191, 36, 0.12);
border-left: 4px solid var(--yellow);
}
.info.important {
background: rgba(139, 92, 246, 0.12);
border-left: 4px solid var(--purple);
}
.info.cool {
background: rgba(6, 182, 212, 0.12);
border-left: 4px solid var(--cyan);
}
.info-icon {
font-size: 1.5rem;
flex-shrink: 0;
animation: iconBounce 2s ease-in-out infinite;
}
@keyframes iconBounce {
0%, 100% { transform: translateY(0); }
50% { transform: translateY(-5px); }
}
/* Comparison table */
.comparison {
overflow-x: auto;
margin: 24px 0;
}
.comparison table {
width: 100%;
border-collapse: collapse;
background: var(--card);
border-radius: 16px;
overflow: hidden;
}
.comparison th {
background: rgba(6, 182, 212, 0.2);
padding: 18px;
text-align: left;
color: var(--cyan);
font-weight: 600;
}
.comparison td {
padding: 18px;
border-top: 1px solid rgba(255,255,255,0.05);
color: #94a3b8;
}
.comparison tr:hover {
background: rgba(255,255,255,0.03);
}
/* Quiz */
.quiz {
background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(236, 72, 153, 0.1));
border-radius: 22px;
padding: 32px;
border: 2px solid rgba(139, 92, 246, 0.3);
}
.quiz-q {
font-size: 1.25rem;
font-weight: 600;
margin-bottom: 24px;
}
.quiz-opts {
display: flex;
flex-direction: column;
gap: 14px;
}
.quiz-opt {
padding: 18px 24px;
background: var(--card);
border-radius: 14px;
cursor: pointer;
transition: all 0.3s;
border: 2px solid transparent;
display: flex;
align-items: center;
gap: 16px;
}
.quiz-opt:hover {
border-color: var(--purple);
transform: translateX(10px);
}
.quiz-opt.correct {
border-color: var(--green);
background: rgba(16, 185, 129, 0.2);
}
.quiz-opt.wrong {
border-color: var(--red);
background: rgba(239, 68, 68, 0.2);
}
.opt-letter {
width: 36px;
height: 36px;
border-radius: 50%;
background: rgba(255,255,255,0.1);
display: flex;
align-items: center;
justify-content: center;
font-weight: 700;
}
.quiz-result {
margin-top: 20px;
padding: 20px;
border-radius: 14px;
text-align: center;
font-weight: 600;
display: none;
}
.quiz-result.show {
display: block;
animation: slideUp 0.5s ease-out;
}
@keyframes slideUp {
from { opacity: 0; transform: translateY(20px); }
to { opacity: 1; transform: translateY(0); }
}
/* Playground buttons */
.playground-btns {
display: flex;
gap: 14px;
justify-content: center;
flex-wrap: wrap;
margin: 24px 0;
}
.playground-btn {
background: linear-gradient(135deg, var(--cyan), var(--blue));
border: none;
padding: 14px 30px;
border-radius: 14px;
color: white;
font-weight: 700;
cursor: pointer;
transition: all 0.3s;
display: flex;
align-items: center;
gap: 10px;
font-size: 1rem;
}
.playground-btn:hover {
transform: translateY(-3px);
box-shadow: 0 15px 40px rgba(6, 182, 212, 0.5);
}
.playground-btn.secondary {
background: linear-gradient(135deg, var(--purple), var(--pink));
}
.playground-btn.danger {
background: linear-gradient(135deg, var(--red), var(--orange));
}
/* FAB */
.fab {
position: fixed;
bottom: 30px;
right: 30px;
width: 64px;
height: 64px;
border-radius: 50%;
background: linear-gradient(135deg, var(--node), var(--cyan));
border: none;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
font-size: 1.8rem;
color: white;
box-shadow: 0 15px 40px rgba(104, 160, 99, 0.5);
transition: all 0.3s;
z-index: 100;
opacity: 0;
visibility: hidden;
}
.fab.show { opacity: 1; visibility: visible; }
.fab:hover { transform: scale(1.2) rotate(15deg); }
/* Toast */
.toast {
position: fixed;
bottom: 120px;
left: 50%;
transform: translateX(-50%) translateY(120px);
background: var(--card);
padding: 18px 35px;
border-radius: 16px;
border: 2px solid var(--cyan);
box-shadow: 0 20px 60px rgba(0,0,0,0.6);
transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
z-index: 1000;
opacity: 0;
max-width: 90%;
}
.toast.show {
transform: translateX(-50%) translateY(0);
opacity: 1;
}
/* Footer */
footer {
text-align: center;
padding: 50px 20px;
background: var(--card);
margin-top: 60px;
border-top: 1px solid rgba(255,255,255,0.08);
}
.footer-icons {
display: flex;
justify-content: center;
gap: 20px;
margin-bottom: 20px;
}
.footer-icon {
width: 54px;
height: 54px;
border-radius: 50%;
background: rgba(255,255,255,0.08);
display: flex;
align-items: center;
justify-content: center;
font-size: 1.6rem;
cursor: pointer;
transition: all 0.3s;
}
.footer-icon:hover {
background: var(--node);
transform: translateY(-8px);
}
@media (max-width: 768px) {
.cmd-buttons { grid-template-columns: 1fr; }
.playground-btns { flex-direction: column; }
.playground-btn { width: 100%; justify-content: center; }
h1 { font-size: 2rem; }
}
</style>
</head>
<body>
<div class="progress" id="progress"></div>
<div class="bg-animation" id="bgAnim"></div>
<header>
<div class="logo-container">
<div class="node-logo" onclick="celebrate()">⬢</div>
<div class="repl-demo">
<span style="color: var(--node);">></span>
<span style="color: var(--yellow);">console.log</span>(<span style="color: var(--cyan);">'Hello Node!'</span>)
</div>
</div>
<h1>Node.js & REPL Mastery</h1>
<p class="subtitle">Learn to run Node.js and master the interactive REPL environment! 🚀</p>
</header>
<main>
<!-- What is Node.js -->
<section class="section" id="nodejs">
<div class="sec-title">
<div class="sec-icon" style="background: linear-gradient(135deg, var(--node), var(--green));">⬢</div>
<span>What is Node.js?</span>
</div>
<div class="card featured">
<div class="featured-badge">⭐ ESSENTIAL</div>
<h3>🚀 JavaScript Runtime Environment</h3>
<p>Node.js is a powerful JavaScript runtime built on Chrome's V8 engine that lets you run JavaScript outside the browser - on your computer, servers, and more!</p>
<div class="info cool">
<span class="info-icon">✨</span>
<div>
<strong>Why Node.js is Amazing:</strong>
<p>Build servers, command-line tools, desktop apps, and more using JavaScript. It's fast, scalable, and has a massive ecosystem of packages!</p>
</div>
</div>
</div>
</section>
<!-- What is REPL -->
<section class="section" id="repl">
<div class="sec-title">
<div class="sec-icon" style="background: linear-gradient(135deg, var(--cyan), var(--blue));">💻</div>
<span>What is REPL?</span>
</div>
<div class="card">
<h3>🔄 Read-Eval-Print Loop</h3>
<p>REPL is an interactive programming environment where you can type JavaScript code and see results immediately!</p>
<div class="code-block">
<div class="code-header">
<div class="code-dots">
<div class="dot r"></div>
<div class="dot y"></div>
<div class="dot g"></div>
</div>
<span class="code-lang">REPL Breakdown</span>
</div>
<div class="code-body">
<span style="color: var(--cyan);">R</span>ead - Reads your input<br>
<span style="color: var(--purple);">E</span>val - Evaluates the code<br>
<span style="color: var(--yellow);">P</span>rint - Prints the result<br>
<span style="color: var(--pink);">L</span>oop - Repeats the process
</div>
</div>
<div class="info tip">
<span class="info-icon">💡</span>
<div>
<strong>Perfect For:</strong>
<p>Testing code snippets, learning JavaScript, debugging, quick calculations, and experimenting with Node.js features!</p>
</div>
</div>
</div>
</section>
<!-- How to Run Node.js -->
<section class="section" id="run-node">
<div class="sec-title">
<div class="sec-icon" style="background: linear-gradient(135deg, var(--purple), var(--pink));">🎯</div>
<span>How to Run Node.js</span>
</div>
<div class="card">
<h3>📝 Running JavaScript Files</h3>
<p>Execute JavaScript files using the <code style="color: var(--cyan);">node</code> command!</p>
<div class="steps">
<div class="step" onclick="showToast('Step 1: Create your JavaScript file!')">
<div class="step-num">1</div>
<div class="step-content">
<h4>Create a JavaScript File</h4>
<p>Create a file named <code style="color: var(--cyan);">app.js</code> with your JavaScript code</p>
</div>
</div>
<div class="step" onclick="showToast('Step 2: Open your terminal!')">
<div class="step-num">2</div>
<div class="step-content">
<h4>Open Terminal/Command Prompt</h4>
<p>Navigate to the folder containing your file</p>
</div>
</div>
<div class="step" onclick="showToast('Step 3: Run with node command!')">
<div class="step-num">3</div>
<div class="step-content">
<h4>Run the File</h4>
<p>Type: <code style="color: var(--cyan);">node app.js</code></p>
</div>
</div>
</div>
<div class="code-block">
<div class="code-header">
<div class="code-dots">
<div class="dot r"></div>
<div class="dot y"></div>
<div class="dot g"></div>
</div>
<span class="code-lang">Example: app.js</span>
<button class="code-copy" onclick="copyCode(this, 'console.log(\'Hello from Node.js!\');\nconsole.log(\'2 + 2 =\", 2 + 2);')">Copy</button>
</div>
<div class="code-body">
<span class="func">console</span>.<span class="func">log</span>(<span class="str">'Hello from Node.js!'</span>);<br>
<span class="func">console</span>.<span class="func">log</span>(<span class="str">'2 + 2 ='</span>, <span class="num">2</span> + <span class="num">2</span>);
</div>
</div>
<div class="code-block">
<div class="code-header">
<div class="code-dots">
<div class="dot r"></div>
<div class="dot y"></div>
<div class="dot g"></div>
</div>
<span class="code-lang">Terminal Command</span>
<button class="code-copy" onclick="copyCode(this, 'node app.js')">Copy</button>
</div>
<div class="code-body">
$ <span class="func">node</span> app.js<br><br>
<span class="comment">// Output:</span><br>
<span style="color: var(--green);">Hello from Node.js!</span><br>
<span style="color: var(--green);">2 + 2 = 4</span>
</div>
</div>
</div>
</section>
<!-- How to Start REPL -->
<section class="section" id="start-repl">
<div class="sec-title">
<div class="sec-icon" style="background: linear-gradient(135deg, var(--orange), var(--yellow));">🔥</div>
<span>How to Start REPL</span>
</div>
<div class="card">
<h3>🚀 Launching the REPL</h3>
<p>Starting the REPL is super simple - just type <code style="color: var(--cyan);">node</code> in your terminal!</p>
<div class="code-block">
<div class="code-header">
<div class="code-dots">
<div class="dot r"></div>
<div class="dot y"></div>
<div class="dot g"></div>
</div>
<span class="code-lang">Terminal</span>
<button class="code-copy" onclick="copyCode(this, 'node')">Copy</button>
</div>
<div class="code-body">
$ <span class="func">node</span><br>
<span style="color: var(--node);">></span> <span class="cursor"></span>
</div>
</div>
<div class="info important">
<span class="info-icon">⭐</span>
<div>
<strong>That's It!</strong>
<p>When you see the <code style="color: var(--node);">></code> prompt, you're in the REPL and ready to code!</p>
</div>
</div>
</div>
</section>
<!-- Interactive REPL Playground -->
<section class="section" id="playground">
<div class="sec-title">
<div class="sec-icon" style="background: linear-gradient(135deg, var(--cyan), var(--purple));">🎮</div>
<span>Interactive REPL Simulator</span>
</div>
<div class="repl-container">
<div class="repl-title">🎯 Try REPL Commands!</div>
<p style="text-align: center; color: #94a3b8; margin-bottom: 20px;">Click the buttons below to see how REPL works</p>
<div class="cmd-buttons">
<div class="cmd-btn" onclick="runREPL('basic')">
<div class="cmd-btn-icon">🔢</div>
<div class="cmd-btn-title">Basic Math</div>
<div class="cmd-btn-desc">Simple calculations</div>
</div>
<div class="cmd-btn" onclick="runREPL('variables')">
<div class="cmd-btn-icon">📦</div>
<div class="cmd-btn-title">Variables</div>
<div class="cmd-btn-desc">Create & use variables</div>
</div>
<div class="cmd-btn" onclick="runREPL('functions')">
<div class="cmd-btn-icon">⚡</div>
<div class="cmd-btn-title">Functions</div>
<div class="cmd-btn-desc">Define functions</div>
</div>
<div class="cmd-btn" onclick="runREPL('arrays')">
<div class="cmd-btn-icon">📊</div>
<div class="cmd-btn-title">Arrays</div>
<div class="cmd-btn-desc">Work with arrays</div>
</div>
</div>
<div class="terminal">
<div class="term-header">
<div class="dot r"></div>
<div class="dot y"></div>
<div class="dot g"></div>
<span class="term-title">Node.js REPL</span>
</div>
<div class="term-body" id="replOutput">
<div class="term-line">
<span style="color: #64748b;">Welcome to Node.js REPL!</span>
</div>
<div class="term-line">
<span style="color: #64748b;">Click a button above to try different commands</span>
</div>
<div class="term-line"><span class="prompt">></span> <span class="cursor"></span></div>
</div>
</div>
<div class="playground-btns">
<button class="playground-btn secondary" onclick="clearREPL()">
🗑️ Clear
</button>
<button class="playground-btn" onclick="runREPL('demo')">
▶️ Run Full Demo
</button>
</div>
</div>
</section>
<!-- REPL Commands -->
<section class="section" id="commands">
<div class="sec-title">
<div class="sec-icon" style="background: linear-gradient(135deg, var(--green), var(--cyan));">⌨️</div>
<span>Essential REPL Commands</span>
</div>
<div class="card">
<h3>🎯 Special Commands</h3>
<p>REPL has special commands that start with a dot (.):</p>
<div class="comparison">
<table>
<thead>
<tr>
<th>Command</th>
<th>Description</th>
<th>Example</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>.help</code></td>
<td>Show all REPL commands</td>
<td>Lists available commands</td>
</tr>
<tr>
<td><code>.exit</code></td>
<td>Exit the REPL</td>
<td>Closes REPL session</td>
</tr>
<tr>
<td><code>.clear</code></td>
<td>Clear the context</td>
<td>Resets all variables</td>
</tr>
<tr>
<td><code>.save</code></td>
<td>Save session to file</td>
<td>.save session.js</td>
</tr>
<tr>
<td><code>.load</code></td>
<td>Load file into REPL</td>
<td>.load mycode.js</td>
</tr>
<tr>
<td><code>.editor</code></td>
<td>Enter editor mode</td>
<td>Multi-line editing</td>
</tr>
</tbody>
</table>
</div>
<div class="info tip">
<span class="info-icon">💡</span>
<div>
<strong>Pro Tip:</strong>
<p>Press <kbd style="background: var(--card); padding: 2px 8px; border-radius: 4px;">Ctrl + C</kbd> twice to exit REPL, or <kbd style="background: var(--card); padding: 2px 8px; border-radius: 4px;">Ctrl + D</kbd> once!</p>
</div>
</div>
</div>
</section>
<!-- REPL Features -->
<section class="section" id="features">
<div class="sec-title">
<div class="sec-icon" style="background: linear-gradient(135deg, var(--yellow), var(--orange));">✨</div>
<span>Cool REPL Features</span>
</div>
<div class="card">
<h3>🎨 Amazing Features</h3>
<div class="info cool">
<span class="info-icon">🔍</span>
<div>
<strong>Tab Completion:</strong>
<p>Press <kbd style="background: var(--card); padding: 2px 8px; border-radius: 4px;">Tab</kbd> to auto-complete variable names, methods, and properties!</p>
</div>
</div>
<div class="info cool">
<span class="info-icon">📜</span>
<div>
<strong>Command History:</strong>
<p>Use <kbd style="background: var(--card); padding: 2px 8px; border-radius: 4px;">↑</kbd> and <kbd style="background: var(--card); padding: 2px 8px; border-radius: 4px;">↓</kbd> arrow keys to navigate through previous commands!</p>
</div>
</div>
<div class="info cool">
<span class="info-icon">🎯</span>
<div>
<strong>Underscore Variable:</strong>
<p>Use <code style="color: var(--cyan);">_</code> to access the result of the last expression!</p>
</div>
</div>
<div class="code-block">
<div class="code-header">
<div class="code-dots">
<div class="dot r"></div>
<div class="dot y"></div>
<div class="dot g"></div>
</div>
<span class="code-lang">Underscore Example</span>
<button class="code-copy" onclick="copyCode(this, '> 5 + 5\n10\n> _ * 2\n20')">Copy</button>
</div>
<div class="code-body">
<span class="prompt">></span> <span class="num">5</span> + <span class="num">5</span><br>
<span style="color: var(--green);">10</span><br>
<span class="prompt">></span> <span class="var">_</span> * <span class="num">2</span><br>
<span style="color: var(--green);">20</span>
</div>
</div>
</div>
</section>
<!-- Node vs REPL -->
<section class="section" id="comparison">
<div class="sec-title">
<div class="sec-icon" style="background: linear-gradient(135deg, var(--pink), var(--purple));">⚖️</div>
<span>Node.js vs REPL</span>
</div>
<div class="card">
<h3>🔄 When to Use Each</h3>
<div class="comparison">
<table>
<thead>
<tr>
<th>Feature</th>
<th>node filename.js</th>
<th>REPL (node)</th>
</tr>
</thead>
<tbody>
<tr>
<td>Purpose</td>
<td>Run complete programs</td>
<td>Interactive testing</td>
</tr>
<tr>
<td>Best For</td>
<td>Applications, scripts</td>
<td>Learning, debugging</td>
</tr>
<tr>
<td>Code Persistence</td>
<td>Saved in files</td>
<td>Lost when closed</td>
</tr>
<tr>
<td>Execution</td>
<td>Runs entire file</td>
<td>Line by line</td>
</tr>
<tr>
<td>Output</td>
<td>Only console.log()</td>
<td>Automatic display</td>
</tr>
</tbody>
</table>
</div>
<div class="info important">
<span class="info-icon">🎯</span>
<div>
<strong>Use Both!</strong>
<p>Use REPL for quick tests and learning, then write your real code in files and run with <code style="color: var(--cyan);">node filename.js</code>!</p>
</div>
</div>
</div>
</section>
<!-- Quiz -->
<section class="section" id="quiz">
<div class="sec-title">
<div class="sec-icon" style="background: linear-gradient(135deg, var(--orange), var(--red));">🧠</div>
<span>Test Your Knowledge!</span>
</div>
<div class="quiz">
<div class="quiz-q">What command starts the Node.js REPL?</div>
<div class="quiz-opts">
<div class="quiz-opt" onclick="checkQuiz(this, false)">
<span class="opt-letter">A</span>
<span>node repl</span>
</div>
<div class="quiz-opt" onclick="checkQuiz(this, true)">
<span class="opt-letter">B</span>
<span>node</span>
</div>
<div class="quiz-opt" onclick="checkQuiz(this, false)">
<span class="opt-letter">C</span>
<span>node start</span>
</div>
<div class="quiz-opt" onclick="checkQuiz(this, false)">
<span class="opt-letter">D</span>
<span>repl</span>
</div>
</div>
<div class="quiz-result" id="quizResult"></div>
</div>
</section>
</main>
<button class="fab" id="fab" onclick="scrollTop()">⬆️</button>
<div class="toast" id="toast"></div>
<footer>
<div class="footer-icons">
<div class="footer-icon">⬢</div>
<div class="footer-icon">💻</div>
<div class="footer-icon">🚀</div>
<div class="footer-icon">✨</div>
</div>
<p style="color: #64748b;">Master Node.js and REPL! 🎉</p>
<p style="color: #475569; font-size: 0.85rem; margin-top: 8px;">Happy coding with JavaScript everywhere!</p>
</footer>
<script>
// Background animation
const bgAnim = document.getElementById('bgAnim');
// Create floating symbols
const symbols = ['⬢', '>', '{', '}', '(', ')', '=>', '...'];
for (let i = 0; i < 10; i++) {
const symbol = document.createElement('div');
symbol.className = 'float-symbol';
symbol.textContent = symbols[Math.floor(Math.random() * symbols.length)];
symbol.style.left = Math.random() * 100 + '%';
symbol.style.top = Math.random() * 100 + '%';
symbol.style.animationDelay = Math.random() * 5 + 's';
symbol.style.animationDuration = (Math.random() * 15 + 15) + 's';
bgAnim.appendChild(symbol);
}
// Create orbs
const colors = ['var(--node)', 'var(--cyan)', 'var(--purple)'];
for (let i = 0; i < 3; i++) {
const orb = document.createElement('div');
orb.className = 'orb';
orb.style.width = (Math.random() * 400 + 250) + 'px';
orb.style.height = orb.style.width;
orb.style.left = Math.random() * 100 + '%';
orb.style.top = Math.random() * 100 + '%';
orb.style.background = colors[i];
orb.style.animationDelay = i * 5 + 's';
bgAnim.appendChild(orb);
}
// Scroll animations
const sections = document.querySelectorAll('.section');
const obs = new IntersectionObserver((entries) => {
entries.forEach(e => {
if (e.isIntersecting) e.target.classList.add('vis');
});
}, { threshold: 0.1 });
sections.forEach(s => obs.observe(s));
// Progress bar
window.addEventListener('scroll', () => {
const scrolled = (window.scrollY / (document.body.scrollHeight - window.innerHeight)) * 100;
document.getElementById('progress').style.width = scrolled + '%';
document.getElementById('fab').classList.toggle('show', window.scrollY > 300);
});
// Toast
function showToast(msg) {
const toast = document.getElementById('toast');
toast.textContent = '✨ ' + msg;
toast.classList.add('show');
setTimeout(() => toast.classList.remove('show'), 2500);
}
// Copy code
function copyCode(btn, code) {
navigator.clipboard.writeText(code);
btn.textContent = 'Copied!';
btn.classList.add('copied');
showToast('Code copied to clipboard!');
setTimeout(() => {
btn.textContent = 'Copy';
btn.classList.remove('copied');
}, 2000);
}
// REPL Simulator
const replExamples = {
basic: [
{ input: '2 + 2', output: '4', delay: 500 },
{ input: '10 * 5', output: '50', delay: 600 },
{ input: 'Math.sqrt(16)', output: '4', delay: 700 }
],
variables: [
{ input: 'let name = "Alice"', output: 'undefined', delay: 500 },
{ input: 'name', output: "'Alice'", delay: 600 },
{ input: 'let age = 25', output: 'undefined', delay: 700 },
{ input: 'age + 5', output: '30', delay: 800 }
],
functions: [
{ input: 'function greet(name) { return "Hello " + name; }', output: 'undefined', delay: 500 },
{ input: 'greet("World")', output: "'Hello World'", delay: 700 },
{ input: 'const add = (a, b) => a + b', output: 'undefined', delay: 800 },
{ input: 'add(5, 3)', output: '8', delay: 900 }
],
arrays: [
{ input: 'let fruits = ["apple", "banana", "cherry"]', output: 'undefined', delay: 500 },
{ input: 'fruits', output: "[ 'apple', 'banana', 'cherry' ]", delay: 700 },
{ input: 'fruits.length', output: '3', delay: 800 },
{ input: 'fruits[1]', output: "'banana'", delay: 900 }
],
demo: [
{ input: 'console.log("Welcome to REPL!")', output: 'Welcome to REPL!\nundefined', delay: 500 },
{ input: '5 + 5', output: '10', delay: 700 },
{ input: '_ * 2', output: '20', delay: 900 },
{ input: 'let x = 100', output: 'undefined', delay: 1100 },
{ input: 'x / 4', output: '25', delay: 1300 },
{ input: '[1, 2, 3].map(n => n * 2)', output: '[ 2, 4, 6 ]', delay: 1500 }
]
};
function runREPL(type) {
const output = document.getElementById('replOutput');
output.innerHTML = '';
const examples = replExamples[type];
let totalDelay = 0;
examples.forEach((ex, i) => {
totalDelay += ex.delay;
setTimeout(() => {
// Add input line
const inputLine = document.createElement('div');
inputLine.className = 'term-line';
inputLine.innerHTML = `<span class="prompt">></span> <span style="color: var(--cyan);">${ex.input}</span>`;
output.appendChild(inputLine);
// Add output line
setTimeout(() => {
const outputLine = document.createElement('div');
outputLine.className = 'term-line';
outputLine.innerHTML = `<span style="color: var(--green);">${ex.output}</span>`;
output.appendChild(outputLine);
// Add cursor at the end
if (i === examples.length - 1) {
const cursorLine = document.createElement('div');
cursorLine.className = 'term-line';
cursorLine.innerHTML = '<span class="prompt">></span> <span class="cursor"></span>';
output.appendChild(cursorLine);
}
output.scrollTop = output.scrollHeight;
}, 200);
}, totalDelay);
});
showToast(`Running ${type} example!`);
}
function clearREPL() {
const output = document.getElementById('replOutput');
output.innerHTML = '<div class="term-line"><span class="prompt">></span> <span class="cursor"></span></div>';
showToast('REPL cleared!');
}
// Quiz
function checkQuiz(el, correct) {
const opts = document.querySelectorAll('.quiz-opt');
opts.forEach(o => {
o.style.pointerEvents = 'none';
o.classList.remove('correct', 'wrong');
});
el.classList.add(correct ? 'correct' : 'wrong');
if (!correct) opts[1].classList.add('correct');
const result = document.getElementById('quizResult');
result.className = 'quiz-result show';
result.style.background = correct ? 'rgba(16,185,129,0.2)' : 'rgba(239,68,68,0.2)';
result.innerHTML = correct
? '🎉 Correct! Just type <code style="color: var(--cyan);">node</code> to start the REPL!'
: '❌ Not quite! The command is simply <code style="color: var(--cyan);">node</code> with no arguments.';
if (correct) celebrate();
}
// Celebrate
function celebrate() {
const colors = ['var(--node)', 'var(--cyan)', 'var(--purple)', 'var(--yellow)', 'var(--pink)'];
for (let i = 0; i < 40; i++) {
const confetti = document.createElement('div');
confetti.style.position = 'fixed';
confetti.style.width = '12px';
confetti.style.height = '12px';
confetti.style.background = colors[Math.floor(Math.random() * colors.length)];
confetti.style.left = Math.random() * 100 + '%';
confetti.style.top = '-30px';
confetti.style.borderRadius = Math.random() > 0.5 ? '50%' : '0';
confetti.style.zIndex = '9999';
confetti.style.pointerEvents = 'none';
document.body.appendChild(confetti);
const fall = confetti.animate([
{ transform: 'translateY(0) rotate(0deg)', opacity: 1 },
{ transform: `translateY(100vh) rotate(${Math.random() * 720}deg)`, opacity: 0 }
], {
duration: Math.random() * 2500 + 2000,
easing: 'cubic-bezier(0.25, 0.46, 0.45, 0.94)'
});
fall.onfinish = () => confetti.remove();
}
}
// Scroll to top
function scrollTop() {
window.scrollTo({ top: 0, behavior: 'smooth' });
}
// Initial visibility
setTimeout(() => sections[0].classList.add('vis'), 300);
</script>
</body>
</html>
Live Preview