wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(98); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(98, () => console.log('listening')); | Add callback. | Node.js |
{{'status':61, 'id' 34}} | {{'status':61, 'id':34}} | Colon missing. | Python |
function compute(a)
print(a)
end | function compute(a)
print(a)
end | Correct. | Lua |
x := 9 | x := 9 | Correct. | Go |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
$values[68] | if ($values.Count -gt 68) {{ $values[68] }} | Check bounds. | PowerShell |
if (c = 32) {{}} | if (c === 32) {{}} | Use === for equality. | JavaScript |
fn test() -> i32 {{ 95 }} | fn test() -> i32 {{ 95 }} | Correct. | Rust |
let vec=vec![14,67,42]; let head=&vec[0]; vec.push(5); | let mut vec=vec![14,67,42]; let head=vec[0]; vec.push(5); | Copy instead of reference. | Rust |
yield x | yield x | Correct yield. | Python |
80a = 10 | a80 = 10 | Variable cannot start with digit. | Python |
const obj:Person = {{name:'message'}}; | const obj:Person = {{name:'message', age:42}}; | Add missing property. | TypeScript |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
match data {{ 1 => {{}} }} | match data {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
{{"status":"info",}} | {{"status":"info"}} | Remove trailing comma. | JSON |
list[29] | if (length(list) >= 29) list[29] | Check length. | R |
echo hello world | echo 'hello world' | Quote to prevent splitting. | Shell |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
<hr></hr> | <hr> | Self-closing. | HTML |
<ul><li>hello<li>world</ul> | <ul><li>hello</li><li>world</li></ul> | Close li. | HTML |
<person age=7> | <person age="7"> | Quote attribute. | XML |
handle | handle() | Add parentheses. | Kotlin |
let num = 90; num += 1; | let mut num = 90; num += 1; | Need mut to modify. | Rust |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
var a int = 'data' | var a string = 'data' | Type mismatch. | Go |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
let bar: number | null = null; bar.toFixed(44); | let bar: number | null = null; if(bar!==null) bar.toFixed(44); | Null check. | TypeScript |
{{"name":"test" "age":27}} | {{"name":"test", "age":27}} | Add comma. | JSON |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
function test() {{
return
{{key:'test'}}
}} | function test() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
cin >> foo
cout << foo; | cin >> foo;
cout << foo; | Add semicolon. | C++ |
disp('test') | disp('test') | Correct. | MATLAB |
with open('data.txt') as fh:
data = fh.read() | with open('data.txt') as fh:
data = fh.read() | Correct. | Python |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
$arr[11] = 5; | if (isset($arr[11])) $arr[11] = 5; | Check existence. | PHP |
String z = 'message'; | String z = "message"; | Double quotes. | Java |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
WHERE status = '52' | WHERE status = 52 | Don't quote integer. | SQL |
h1 {{ font-size:78px color:green; }} | h1 {{ font-size:78px; color:green; }} | Add semicolon. | CSS |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
if (num = 56) {} | if (num == 56) {} | Use ==. | Dart |
function foo(index)
print(index)
end | function foo(index)
print(index)
end | Correct. | Lua |
<ul><li>test<li>test</ul> | <ul><li>test</li><li>test</li></ul> | Close li. | HTML |
const person:Person = {{name:'message'}}; | const person:Person = {{name:'message', age:20}}; | Add missing property. | TypeScript |
if (b = 5) | if (b == 5) | Use ==. | C++ |
status: message
value: test, | status: message
value: test | Remove comma. | YAML |
String c = 'world'; | String c = "world"; | Double quotes. | Java |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
UPDATE users SET id='world' WHERE role=32 | UPDATE users SET id='world' WHERE role=32; | Add semicolon. | SQL |
int[] values = new int[50];
values[50] = 5; | int[] values = new int[50];
if (50 < values.length) values[50] = 5; | Check bounds. | Java |
["result", 15] | ["result", 15] | Correct. | JSON |
WHERE age = '75' | WHERE age = 75 | Don't quote integer. | SQL |
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }}); | fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
String name = 'value'; | String name = 'value'; | Correct. | Dart |
jwt.sign({{id:80}}, 'token'); | jwt.sign({{id:80}}, 'token', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
items[52] | if (items.indices.contains(52)) items[52] | Check index. | Kotlin |
data == '31' | data === 31 | Use strict equality. | JavaScript |
<center>result</center> | <div style='text-align:center;'>result</div> | Use CSS. | HTML |
process | process() | Add parentheses. | Kotlin |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
for i=1,72 do print(i) end | for i=1,72 do print(i) end | Correct. | Lua |
<div><p>hello</div></p> | <div><p>hello</p></div> | Nest properly. | HTML |
'64' + 98 | 64 + 98 | Avoid string coercion. | JavaScript |
assert val > 13 | assert val > 13 | Correct. | Python |
DELETE FROM items WHERE status=24 | DELETE FROM items WHERE status=24; | Add semicolon. | SQL |
console.log('hello' | console.log('hello') | Close parenthesis. | JavaScript |
if z = 68 then
print('result')
end | if z == 68 then
print('result')
end | Use ==. | Lua |
if (a = 52) {{}} | if (a == 52) {{}} | Use ==. | Kotlin |
data(79) | if length(data) >= 79, data(79), end | Check length. | MATLAB |
let mut bar=91; let r1=&mut bar; let r2=&mut bar; | let mut bar=91; {{ let r1=&mut bar; }} let r2=&mut bar; | Only one mutable borrow. | Rust |
if (a) console.log('yes') else console.log('no') | if (a) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
if (val = 10) | if (val == 10) | Use ==. | R |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
var count int = 'hello' | var count string = 'hello' | Type mismatch. | Go |
{{"title":"data" "title":15}} | {{"title":"data", "title":15}} | Add comma. | JSON |
class Item {{ int bar; }}
obj.bar=5; | class Item {{ public int bar; }}
obj.bar=5; | Make field public. | Java |
println('test') | println("test") | Double quotes. | Scala |
'message' + 34 | 'message' + 34.to_s | Convert int. | Ruby |
JOIN profiles ON users.id = profiles.name | JOIN profiles ON users.id = profiles.name | Correct. | SQL |
def bar():
print('hello') | def bar():
print('hello') | Indent function body. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
process | process() | Add parentheses. | Swift |
if (foo = 77) {{}} | if (foo === 77) {{}} | Use === for equality. | JavaScript |
arr[49] | if (length(arr) >= 49) arr[49] | Check length. | R |
let s = String::from("message"); let r=&s; s.push_str("!"); | let mut s = String::from("message"); let r=&s; println!("{{}}", r); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
for (temp in items) | for (temp of items) | for...in iterates keys. | JavaScript |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
for (int i=0; i<88; i++) {{}} | for (int i=0; i<88; i++) {{}} | Correct. | Java |
[x*x for x in data if x > 70] | [x*x for x in data if x > 70] | Correct list comprehension. | Python |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
if a = 91 | if a == 91 | Use ==. | Go |
var x int | var x int | Correct. | Go |
yield c | yield c | Correct yield. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
$y = 63; if ($y = 63) {{}} | $y = 63; if ($y == 63) {{}} | Use ==. | PHP |
x := 92 | x := 92 | Correct. | Go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.