Web

Interactive Code Playground Demo

Try out our interactive code playground with live examples, challenges, and sandboxes

K

Kambrathi

Author

January 16, 2024

Published

8 min read

Read time

Interactive Code Playground Demo

๐ŸŽฎ Interactive Code Playground Demo

Welcome to the interactive code playground! This page demonstrates all three components you can use in your courses.


1. ๐Ÿ“ CodePlayground - Live Code Execution

Try writing and running JavaScript code directly in your browser:

Try JavaScript

JavaScript
โœ“ Auto-saved
๐Ÿ’ก Tip: Press Ctrl+Enter to run codeLines: 12 | Characters: 252

Features You Can Try:

  • โœ๏ธ Edit the code and click โ€œRun Codeโ€
  • ๐Ÿ’พ Your changes are auto-saved
  • ๐Ÿ“‹ Copy code to clipboard
  • โฌ‡๏ธ Download as a file
  • ๐Ÿ”— Share your code via URL

2. ๐ŸŽฏ CodeChallenge - Interactive Coding Challenges

Test your skills with this FizzBuzz challenge:

FizzBuzz Challenge

EASY

Write a function that returns 'Fizz' for multiples of 3, 'Buzz' for multiples of 5, and 'FizzBuzz' for multiples of both.

๐Ÿ’ก Write a function that passes all test cases5 test cases

Challenge Features:

  • โœ… Automatic test case validation
  • ๐Ÿ’ก Progressive hints (unlock one at a time)
  • ๐Ÿ‘€ View solution when stuck
  • ๐Ÿ“Š Score tracking
  • ๐Ÿ’พ Auto-save your progress

3. ๐Ÿ”ง Advanced Challenge - Array Manipulation

Ready for something harder? Try this array challenge:

Find Duplicates in Array

MEDIUM

Write a function that finds all duplicate values in an array and returns them in a new array (no duplicates in result).

๐Ÿ’ก Write a function that passes all test cases4 test cases

4. ๐Ÿ–๏ธ CodeSandbox - Full Project Environments

React Todo App Sandbox

Explore a complete React project running in the browser:

React Todo App

CodeSandbox
Open in CodeSandbox
๐Ÿ’ก Edit the code directly in the sandbox

Note: Replace sandboxId with your actual CodeSandbox ID

Features:

  • ๐ŸŽจ Full IDE experience in browser
  • ๐Ÿ“ฆ Install npm packages
  • ๐Ÿ”„ Live preview
  • ๐ŸŒ“ Dark/light theme
  • ๐Ÿ“ฑ Responsive preview

5. โšก StackBlitz Integration

Try this Vite + React starter:

Vite + React Starter

StackBlitz
Open in StackBlitz
๐Ÿ’ก Edit the code directly in the sandbox

Note: Replace stackblitzId with your actual StackBlitz project ID


6. ๐Ÿ’ป TypeScript Playground

TypeScript Example

TypeScript
โœ“ Auto-saved
๐Ÿ’ก Tip: Press Ctrl+Enter to run codeLines: 18 | Characters: 344

7. ๐Ÿ Python Code Display

Python Example (Display Only)

Python
โœ“ Auto-saved
๐Ÿ’ก Tip: Press Ctrl+Enter to run codeLines: 15 | Characters: 349

Note: Python execution requires backend support. This shows syntax highlighting and editing.


8. โ˜• Java Code Display

Java Example (Display Only)

Java
โœ“ Auto-saved
๐Ÿ’ก Tip: Press Ctrl+Enter to run codeLines: 19 | Characters: 449

๐ŸŽ“ How to Use in Your Courses

For Simple Code Examples:

<CodePlayground
  language="javascript"
  title="Your Title"
  initialCode={`console.log("Hello!");`}
  client:load
/>

For Coding Challenges:

<CodeChallenge
  title="Challenge Title"
  difficulty="easy"
  initialCode={`function solve() { }`}
  testCases={[
    { input: 5, expected: 25 }
  ]}
  solution={`function solve(n) { return n * n; }`}
  hints={["Think about multiplication"]}
  client:load
/>

For Full Projects:

<CodeSandbox
  sandboxId="your-sandbox-id"
  title="Project Title"
  client:load
/>

๐Ÿš€ Next Steps

  1. Practice: Try solving the challenges above
  2. Experiment: Modify the code examples
  3. Create: Use these components in your own courses
  4. Share: Share your solutions with friends

Happy coding! ๐ŸŽ‰


๐Ÿ“š Learn More

K

Kambrathi

Published on January 16, 2024