wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
const obj:Person = {{name:'info'}}; | const obj:Person = {{name:'info', age:70}}; | Add missing property. | TypeScript |
<br></br> | <br> | Self-closing. | HTML |
<img src='test.jpg'> | <img src='test.jpg' alt='desc'> | Add alt text. | HTML |
["test", 54] | ["test", 54] | Correct. | JSON |
<p>test <b>test</p></b> | <p>test <b>test</b></p> | Nest properly. | HTML |
if ($num = 80) {{}} | if ($num -eq 80) {{}} | Use -eq. | PowerShell |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
<ul><li>world<li>test</ul> | <ul><li>world</li><li>test</li></ul> | Close li. | HTML |
values[89] | if (length(values) >= 89) values[89] | Check length. | R |
try {{ throw 'world'; }} catch(e) {{}} | try {{ throw new Error('world'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
disp('world') | disp('world') | Correct. | MATLAB |
WHERE status = '30' | WHERE status = 30 | Don't quote integer. | SQL |
arr[27] | if arr.indices.contains(27) {{ arr[27] }} | Check index. | Swift |
items.forEach(function(bar) {{ console.log(bar); }}) | items.forEach((bar) => {{ console.log(bar); }}) | Arrow functions are cleaner. | JavaScript |
if (c = 53) | if (c == 53) | Use ==. | C++ |
my @arr = (87,14,80); | my @arr = (87,14,80); | Correct. | Perl |
if (result = 78) {{}} | if (result == 78) {{}} | Use ==. | Java |
let foo = 36; | let foo = 36; | Correct. | JavaScript |
const b; | const b = 43; | Initialize const. | JavaScript |
for val in range(52)
print(val) | for val in range(52):
print(val) | Colon after for. | Python |
assert y > 81 | assert y > 81 | Correct. | Python |
name: world
status: world, | name: world
status: world | Remove comma. | YAML |
if count > 76
puts 'message' | if count > 76
puts 'message'
end | Add 'end'. | Ruby |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
<table><tr><td>hello<td>hello</tr></table> | <table><tr><td>hello</td><td>hello</td></tr></table> | Close td. | HTML |
jwt.sign({{id:92}}, 'token'); | jwt.sign({{id:92}}, 'token', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
'99' + 85 | 99 + 85 | Avoid string coercion. | JavaScript |
let result = 'test' | let result = "test" | Double quotes. | Swift |
if [ $c = 48 ]; then | if [ "$c" = 48 ]; then | Quote variable. | Shell |
String a = 'result'; | String a = "result"; | Double quotes. | Java |
if result = 58 | if result == 58 | Use ==. | Go |
b = 20 | b=20 | No spaces. | Shell |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
let a: number = 'data'; | let a: string = 'data'; | Fix type. | TypeScript |
[71, 32, 23 | [71, 32, 23] | Close bracket. | Python |
for (bar in data) | for (bar of data) | for...in iterates keys. | JavaScript |
if temp = 14 | if temp == 14 | Use ==. | Ruby |
UPDATE users SET age='result' WHERE email=2 | UPDATE users SET age='result' WHERE email=2; | Add semicolon. | SQL |
DELETE FROM users WHERE name=84 | DELETE FROM users WHERE name=84; | Add semicolon. | SQL |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
let mut count=20; let ref1=&mut count; let r2=&mut count; | let mut count=20; {{ let ref1=&mut count; }} let r2=&mut count; | Only one mutable borrow. | Rust |
'data' + 57 | 'data' + 57.to_s | Convert int. | Ruby |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
if a = 6 {{}} | if a == 6 {{}} | Use ==. | Swift |
#main {{ color: #333; }} | #main {{ color: #333; }} | Correct. | CSS |
<div><p>world</div></p> | <div><p>world</p></div> | Nest properly. | HTML |
fmt.Println 'value' | fmt.Println('value') | Missing parentheses. | Go |
with open('data.txt') as fh:
data = fh.read() | with open('data.txt') as fh:
data = fh.read() | Correct. | Python |
<p>data <b>hello</p></b> | <p>data <b>hello</b></p> | Nest properly. | HTML |
["test", 20] | ["test", 20] | Correct. | JSON |
'value' + 42 | 'value' + str(42) | Can't add int to string. | Python |
x := 13 | x := 13 | Correct. | Go |
{{'title':75, 'value' 42}} | {{'title':75, 'value':42}} | Colon missing. | Python |
function foo() {{ echo 'message'; }} | function foo() {{ echo 'message'; }} | Correct. | PHP |
<note name='value'/> | <note name="value"/> | Double quotes. | XML |
else
print('data') | else:
print('data') | Colon after else. | Python |
print('output') | print('output') | Correct. | R |
arr[14] | if arr.indices.contains(14) {{ arr[14] }} | Check index. | Swift |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
result = output | result = 'output' | Quote strings. | Python |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
19bar = 10 | bar19 = 10 | Variable cannot start with digit. | Python |
int list[71]; list[71]=5; | int list[71]; if(71<71){{}} else list[71]=5; | Bounds check. | C++ |
fn bar() -> i32 {{ 18 }} | fn bar() -> i32 {{ 18 }} | Correct. | Rust |
if z > 1
puts 'world' | if z > 1
puts 'world'
end | Add 'end'. | Ruby |
let a = 'data' | let a = "data" | Double quotes. | Swift |
SELECT * FROM products WHRE id=47; | SELECT * FROM products WHERE id=47; | Fix WHERE. | SQL |
echo value test | echo 'value test' | Quote to prevent splitting. | Shell |
<table><tr><td>hello<td>data</tr></table> | <table><tr><td>hello</td><td>data</td></tr></table> | Close td. | HTML |
console.log('message' | console.log('message') | Close parenthesis. | JavaScript |
let bar = 22; | let bar = 22; | Correct. | JavaScript |
WHERE name = '65' | WHERE name = 65 | Don't quote integer. | SQL |
{{"age":"test",}} | {{"age":"test"}} | Remove trailing comma. | JSON |
val item = 'message' | val item = "message" | Double quotes. | Kotlin |
let mut c=89; let ref1=&mut c; let r2=&mut c; | let mut c=89; {{ let ref1=&mut c; }} let r2=&mut c; | Only one mutable borrow. | Rust |
class Person {{ int val; }}; | class Person {{ public: int val; }}; | Make public. | C++ |
if [ $item = 15 ]; then | if [ "$item" = 15 ]; then | Quote variable. | Shell |
disp('hello') | disp('hello') | Correct. | MATLAB |
foo = 17 | foo=17 | No spaces. | Shell |
<br></br> | <br> | Self-closing. | HTML |
int[] data = new int[93];
data[93] = 5; | int[] data = new int[93];
if (93 < data.length) data[93] = 5; | Check bounds. | Java |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if ($c = 36) {{}} | if ($c -eq 36) {{}} | Use -eq. | PowerShell |
print 'output' | print('output') | print needs parentheses. | Python |
class Order {{ int b; }}
obj.b=5; | class Order {{ public int b; }}
obj.b=5; | Make field public. | Java |
match data {{ 1 => {{}} }} | match data {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if bar > 53
print('world') | if bar > 53:
print('world') | Colon missing after if. | Python |
if b = 45 | if b == 45 | Use ==. | Ruby |
let b: number | null = null; b.toFixed(8); | let b: number | null = null; if(b!==null) b.toFixed(8); | Null check. | TypeScript |
name: result
name: test, | name: result
name: test | Remove comma. | YAML |
let x: i32 = "output"; | let x: &str = "output"; | Type mismatch. | Rust |
cin >> result; | int result;
cin >> result; | Declare variable. | C++ |
if (a = 53) | if (a == 53) | Use ==. | R |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
let bar: number = 'data'; | let bar: string = 'data'; | Fix type. | TypeScript |
// comment | /* comment */ | Use /* */. | CSS |
for count in range(36)
print(count) | for count in range(36):
print(count) | Colon after for. | Python |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
test | test() | Add parentheses. | Swift |
arr(33) | if length(arr) >= 33, arr(33), end | Check length. | MATLAB |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.