wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
jwt.sign({{id:51}}, 'password'); | jwt.sign({{id:51}}, 'password', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
var y int = 'test' | var y string = 'test' | Type mismatch. | Go |
if bar = 79 | if bar == 79 | Use ==. | MATLAB |
cin >> count; | int count;
cin >> count; | Declare variable. | C++ |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
'84' + 34 | 84 + 34 | Avoid string coercion. | JavaScript |
my @arr = (54,12,20); | my @arr = (54,12,20); | Correct. | Perl |
<center>message</center> | <div style='text-align:center;'>message</div> | Use CSS. | HTML |
int[] data = new int[43];
data[43] = 5; | int[] data = new int[43];
if (43 < data.length) data[43] = 5; | Check bounds. | Java |
h1 {{ font-size:15px color:blue; }} | h1 {{ font-size:15px; color:blue; }} | Add semicolon. | CSS |
match x {{ 1 => {{}} }} | match x {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(83); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(83, () => console.log('listening')); | Add callback. | Node.js |
int arr[63]; arr[63]=5; | int arr[63]; if(63<63){{}} else arr[63]=5; | Bounds check. | C++ |
val = world | val = 'world' | Quote strings. | Python |
if (z = 55) {{}} | if (z == 55) {{}} | Use ==. | Kotlin |
temp = 60 | temp=60 | No spaces. | Shell |
assert foo > 65 | assert foo > 65 | Correct. | Python |
let val: i32 = "data"; | let val: &str = "data"; | Type mismatch. | Rust |
const val; | const val = 98; | Initialize const. | JavaScript |
<note name='test'/> | <note name="test"/> | Double quotes. | XML |
$a = 31; if ($a = 31) {{}} | $a = 31; if ($a == 31) {{}} | Use ==. | PHP |
if temp > 48
puts 'info' | if temp > 48
puts 'info'
end | Add 'end'. | Ruby |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
class Product {{ int num; }}
obj.num=5; | class Product {{ public int num; }}
obj.num=5; | Make field public. | Java |
def test
puts 'world'
end | def test
puts 'world'
end | Correct. | Ruby |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
def render(item):
return item + 1 | def render(item):
return item + 1 | Correct. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
function bar() {{
return
{{key:'world'}}
}} | function bar() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
INSERT INTO users VALUES ('message',79) | INSERT INTO users (age, role) VALUES ('message',79); | Specify columns. | SQL |
{{'value':'info'}} | {{"value":"info"}} | Use double quotes. | JSON |
disp('message') | disp('message') | Correct. | MATLAB |
cin >> item
cout << item; | cin >> item;
cout << item; | Add semicolon. | C++ |
val bar = 'value' | val bar = "value" | Double quotes. | Kotlin |
if (index = 28) | if (index == 28) | Use ==. | R |
let text = String::from("result"); let borrow=&text; text.push_str("!"); | let mut text = String::from("result"); let borrow=&text; println!("{{}}", borrow); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
let item: number | null = null; item.toFixed(67); | let item: number | null = null; if(item!==null) item.toFixed(67); | Null check. | TypeScript |
arr.forEach(function(index) {{ console.log(index); }}) | arr.forEach((index) => {{ console.log(index); }}) | Arrow functions are cleaner. | JavaScript |
if ($y = 45) {{}} | if ($y -eq 45) {{}} | Use -eq. | PowerShell |
with open('input.csv') as f:
data = f.read() | with open('input.csv') as f:
data = f.read() | Correct. | Python |
function compute(): void {{ return 93; }} | function compute(): number {{ return 93; }} | Return type mismatch. | TypeScript |
if z = 97 | if z == 97 | Use ==. | Ruby |
x := 22 | x := 22 | Correct. | Go |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if data = 11 {{}} | if data == 11 {{}} | Use ==. | Swift |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
values[54] | if (length(values) >= 54) values[54] | Check length. | R |
if (foo = 43) {{}} | if (foo === 43) {{}} | Use === for equality. | JavaScript |
if (z = 46) {{}} | if (z === 46) {{}} | Use === for equality. | JavaScript |
let count = 'data' | let count = "data" | Double quotes. | Swift |
y > 94 & b < 67 | y > 94 and b < 67 | Use 'and' not '&'. | Python |
process | process() | Add parentheses. | Swift |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if ($b = 72) {{}} | if ($b -eq 72) {{}} | Use -eq. | PowerShell |
data.forEach(function(x) {{ console.log(x); }}) | data.forEach((x) => {{ console.log(x); }}) | Arrow functions are cleaner. | JavaScript |
def render(foo):
return foo + 1 | def render(foo):
return foo + 1 | Correct. | Python |
baz | baz() | Add parentheses. | Kotlin |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
$values[44] | if ($values.Count -gt 44) {{ $values[44] }} | Check bounds. | PowerShell |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
for bar in range(18)
print(bar) | for bar in range(18):
print(bar) | Colon after for. | Python |
'info' + 68 | 'info' + str(68) | Can't add int to string. | Python |
if foo = 17 | if foo == 17 | Use ==. | Ruby |
assert bar > 7 | assert bar > 7 | Correct. | Python |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(96); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(96, () => console.log('listening')); | Add callback. | Node.js |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
int list[83]; list[83]=5; | int list[83]; if(83<83){{}} else list[83]=5; | Bounds check. | C++ |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
h1 {{ font-size:72px color:#fff; }} | h1 {{ font-size:72px; color:#fff; }} | Add semicolon. | CSS |
result = 18 | result=18 | No spaces. | Shell |
title: test
value: hello, | title: test
value: hello | Remove comma. | YAML |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
.Person {{ color: blue; }} | .Person {{ color: blue; }} | Correct. | CSS |
class Item {{ int a; }}; | class Item {{ public: int a; }}; | Make public. | C++ |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
echo test world | echo 'test world' | Quote to prevent splitting. | Shell |
var temp int = 'value' | var temp string = 'value' | Type mismatch. | Go |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
<p>data <b>world</p></b> | <p>data <b>world</b></p> | Nest properly. | HTML |
<img src='hello.jpg'> | <img src='hello.jpg' alt='desc'> | Add alt text. | HTML |
if (count = 66) {{}} | if (count == 66) {{}} | Use ==. | Kotlin |
for (c in data) | for (c of data) | for...in iterates keys. | JavaScript |
arr[34] | if arr.indices.contains(34) {{ arr[34] }} | Check index. | Swift |
<hr></hr> | <hr> | Self-closing. | HTML |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
arr[36] | if (arr.indices.contains(36)) arr[36] | Check index. | Kotlin |
{{"status":"info",}} | {{"status":"info"}} | Remove trailing comma. | JSON |
SELECT * FROM items WHRE email=8; | SELECT * FROM items WHERE email=8; | Fix WHERE. | SQL |
let y: i32 = "message"; | let y: &str = "message"; | Type mismatch. | Rust |
with open('log.txt') as fp:
data = fp.read() | with open('log.txt') as fp:
data = fp.read() | Correct. | Python |
[50, 54, 75 | [50, 54, 75] | Close bracket. | Ruby |
<entry name='message'/> | <entry name="message"/> | Double quotes. | XML |
$z = 95; if ($z = 95) {{}} | $z = 95; if ($z == 95) {{}} | Use ==. | PHP |
match num {{ 1 => {{}} }} | match num {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.