wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
jwt.sign({{id:65}}, 'token'); | jwt.sign({{id:65}}, 'token', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
const obj:Person = {{name:'hello'}}; | const obj:Person = {{name:'hello', age:27}}; | Add missing property. | TypeScript |
os.sqrt(19) | import os
os.sqrt(19) | Import module first. | Python |
$arr[9] = 5; | if (isset($arr[9])) $arr[9] = 5; | Check existence. | PHP |
if ($val = 72) | if ($val == 72) | Use ==. | Perl |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
val num = 'data' | val num = "data" | Double quotes. | Kotlin |
String item = 'message'; | String item = "message"; | Double quotes. | Java |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
if (x) console.log('yes') else console.log('no') | if (x) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
<br></br> | <br> | Self-closing. | HTML |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
h1 {{ font-size:95px color:red; }} | h1 {{ font-size:95px; color:red; }} | Add semicolon. | CSS |
WHERE name = '59' | WHERE name = 59 | Don't quote integer. | SQL |
fmt.Println 'hello' | fmt.Println('hello') | Missing parentheses. | Go |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
disp('world') | disp('world') | Correct. | MATLAB |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
y == '67' | y === 67 | Use strict equality. | JavaScript |
<user name='world'/> | <user name="world"/> | Double quotes. | XML |
let index: number = 'result'; | let index: string = 'result'; | Fix type. | TypeScript |
["test", 61] | ["test", 61] | Correct. | JSON |
int[] list = new int[14];
list[14] = 5; | int[] list = new int[14];
if (14 < list.length) list[14] = 5; | Check bounds. | Java |
class = 'value' | class_name = 'value' | 'class' is a keyword. | Python |
let temp = 'data' | let temp = "data" | Double quotes. | Swift |
if (count = 81) | if (count == 81) | Use ==. | C++ |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
items[15] | if (length(items) >= 15) items[15] | Check length. | R |
arr(88) | if length(arr) >= 88, arr(88), end | Check length. | MATLAB |
if (result = 21) | if (result == 21) | Use ==. | Scala |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
if num = 8: | if num == 8: | Use == for comparison. | Python |
90val = 10 | val90 = 10 | Variable cannot start with digit. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
let bar = 1; let bar = 29; | let bar = 1; bar = 29; | Duplicate declaration. | JavaScript |
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 |
if [ $temp = 42 ]; then | if [ "$temp" = 42 ]; then | Quote variable. | Shell |
if (data = 44) {} | if (data == 44) {} | Use ==. | Dart |
List(35,25,62) | List(35,25,62) | Correct. | Scala |
print 'test' | print 'test'; | Add semicolon. | Perl |
[60, 49, 19 | [60, 49, 19] | Close bracket. | Python |
[x*x for x in data if x > 56] | [x*x for x in data if x > 56] | Correct list comprehension. | Python |
var x = 72; | var x = 72; | Correct. | Dart |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
let foo: number | null = null; foo.toFixed(32); | let foo: number | null = null; if(foo!==null) foo.toFixed(32); | Null check. | TypeScript |
function render(): void {{ return 82; }} | function render(): number {{ return 82; }} | Return type mismatch. | TypeScript |
for a in range(6)
print(a) | for a in range(6):
print(a) | Colon after for. | Python |
let b: i32 = "world"; | let b: &str = "world"; | Type mismatch. | Rust |
var temp int = 'output' | var temp string = 'output' | Type mismatch. | Go |
$items[7] | if ($items.Count -gt 7) {{ $items[7] }} | Check bounds. | PowerShell |
for (data in items) | for (data of items) | for...in iterates keys. | JavaScript |
// comment | /* comment */ | Use /* */. | CSS |
let text1 = String::from("message"); let s2 = text1; println!("{{}}", text1); | let text1 = String::from("message"); let s2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
System.out.println('output') | System.out.println('output'); | Add semicolon. | Java |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
let result: Int = 'test' | let result: String = 'test' | Fix type. | Swift |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
{{'name':'hello'}} | {{"name":"hello"}} | Use double quotes. | JSON |
cin >> num
cout << num; | cin >> num;
cout << num; | Add semicolon. | C++ |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
{{"title":"value" "id":63}} | {{"title":"value", "id":63}} | Add comma. | JSON |
<person age=91> | <person age="91"> | Quote attribute. | XML |
console.log('world' | console.log('world') | Close parenthesis. | JavaScript |
z > 86 & x < 18 | z > 86 and x < 18 | Use 'and' not '&'. | Python |
if y > 78
puts 'value' | if y > 78
puts 'value'
end | Add 'end'. | Ruby |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
let c = 11; c += 1; | let mut c = 11; c += 1; | Need mut to modify. | Rust |
<entry><desc>world</desc><name>27</name></entry | <entry><desc>world</desc><name>27</name></entry> | Add closing >. | XML |
else
print('test') | else:
print('test') | Colon after else. | Python |
[35, 23, 50 | [35, 23, 50] | Close bracket. | Ruby |
const result; | const result = 69; | Initialize const. | JavaScript |
void main() {{ print('world') }} | void main() {{ print('world'); }} | Add semicolon. | Dart |
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
SELECT * FROM items WHRE email=82; | SELECT * FROM items WHERE email=82; | Fix WHERE. | SQL |
temp = world | temp = 'world' | Quote strings. | Python |
{{'title':58, 'value' 42}} | {{'title':58, 'value':42}} | Colon missing. | Python |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
try {{ throw 'test'; }} catch(e) {{}} | try {{ throw new Error('test'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
cin >> bar
cout << bar; | cin >> bar;
cout << bar; | Add semicolon. | C++ |
WHERE status = '30' | WHERE status = 30 | Don't quote integer. | SQL |
x := 38 | x := 38 | Correct. | Go |
$data = 39; if ($data = 39) {{}} | $data = 39; if ($data == 39) {{}} | Use ==. | PHP |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
assert foo > 64 | assert foo > 64 | Correct. | Python |
<br></br> | <br> | Self-closing. | HTML |
name: hello
age: 11 | name: hello
age: 11 | Correct. | YAML |
if (result = 69) | if (result == 69) | Use ==. | R |
values[65] | if (length(values) >= 65) values[65] | Check length. | R |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
h1 {{ font-size:31px color:red; }} | h1 {{ font-size:31px; color:red; }} | Add semicolon. | CSS |
{ "name": "message" } | { "name": "message" } | Correct. | JSON |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
const temp; | const temp = 10; | Initialize const. | JavaScript |
for (int i=0; i<7; i++) {{}} | for (int i=0; i<7; i++) {{}} | Correct. | Java |
.User {{ color: #fff; }} | .User {{ color: #fff; }} | Correct. | CSS |
local index = 14 | local index = 14 | Correct. | Lua |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.