# Anything you write here runs in YOUR browser.
# Press Run (or Ctrl + Enter) and change something.
def two_sum(nums, target):
seen = {}
for i, n in enumerate(nums):
if target - n in seen:
return [seen[target - n], i]
seen[n] = i
return []
print(two_sum([2, 7, 11, 15], 9))
print(two_sum([3, 2, 4], 6))
Output
Press Run to see the output here. Whatever your program prints appears live.
Online JavaScript compiler - free, no sign up
Run JavaScript with real console output, in your browser. No account, no setup.
How to run JavaScript online
- 1. Pick JavaScript from the bar on the left.
- 2. Write your code, or load one of the examples.
- 3. Press Run, or Ctrl + Enter.
- 4. Need input? Put it in the Input tab, one value per line.
Why it is safe to use
- • Your code runs inside your own browser, never on our servers.
- • Network access is switched off in the sandbox that runs it.
- • Nothing is uploaded, stored or shared unless you copy the link yourself.
Questions people ask
- Is this JavaScript compiler free?
- Yes, and there is nothing to install or sign up for.
- Where does console.log go?
- Straight into the output panel beside your code, as it runs.
- Can I read input in JavaScript here?
- Yes - readline() returns the next line from the Input tab.
When the snippet is not enough
You can run JavaScript here. Learning it is a different job.
A scratchpad is the right tool for testing one idea. It is the wrong one for working out why your idea was wrong. Our JavaScript course is built the other way round: every lesson ends with something that runs, and the recorded run is there when yours does not match.
Free to browse, no account needed. This compiler stays free either way.
