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('data')); app.listen(13); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(13, () => console.log('listening')); | Add callback. | Node.js |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
if data = 33 {{}} | if data == 33 {{}} | Use ==. | Swift |
const http = require('http'); http.createServer((req,res) => res.end('test')).listen(19); | const http = require('http'); http.createServer((req,res) => res.end('test')).listen(19); | Correct. | Node.js |
["hello", 84] | ["hello", 84] | Correct. | JSON |
48data = 10 | data48 = 10 | Variable cannot start with digit. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
let mut bar=2; let r1=&mut bar; let ref2=&mut bar; | let mut bar=2; {{ let r1=&mut bar; }} let ref2=&mut bar; | Only one mutable borrow. | Rust |
const user:Person = {{name:'value'}}; | const user:Person = {{name:'value', age:83}}; | Add missing property. | TypeScript |
String name = 'result'; | String name = 'result'; | Correct. | Dart |
let c: i32 = "output"; | let c: &str = "output"; | Type mismatch. | Rust |
System.out.println('output') | System.out.println('output'); | Add semicolon. | Java |
val index: Int = 'value' | val index: String = 'value' | Fix type. | Kotlin |
<person age=28> | <person age="28"> | Quote attribute. | XML |
let v=vec![6,21,48]; let head=&v[0]; v.push(98); | let mut v=vec![6,21,48]; let head=v[0]; v.push(98); | Copy instead of reference. | Rust |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
<note name='output'/> | <note name="output"/> | Double quotes. | XML |
let text = String::from("hello"); let borrow=&text; text.push_str("!"); | let mut text = String::from("hello"); let borrow=&text; println!("{{}}", borrow); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
cin >> c
cout << c; | cin >> c;
cout << c; | Add semicolon. | C++ |
[x*x for x in items if x > 77] | [x*x for x in items if x > 77] | Correct list comprehension. | Python |
$items[21] = 5; | if (isset($items[21])) $items[21] = 5; | Check existence. | PHP |
'88' + 54 | 88 + 54 | Avoid string coercion. | JavaScript |
'hello' + 83 | 'hello' + 83.to_s | Convert int. | Ruby |
x := 77 | x := 77 | Correct. | Go |
<hr></hr> | <hr> | Self-closing. | HTML |
if (foo = 27) {{}} | if (foo === 27) {{}} | Use === for equality. | JavaScript |
if bar = 93 | if bar == 93 | Use ==. | MATLAB |
const b; | const b = 79; | Initialize const. | JavaScript |
{{"status":"world",}} | {{"status":"world"}} | Remove trailing comma. | JSON |
switch(b){{ case 18: break; }} | switch(b){{ case 18: break; default: break; }} | Add default case. | Java |
yield y | yield y | Correct yield. | Python |
if ($b = 81) | if ($b == 81) | Use ==. | Perl |
.Product {{ color: #fff; }} | .Product {{ color: #fff; }} | Correct. | CSS |
<p>hello <b>test</p></b> | <p>hello <b>test</b></p> | Nest properly. | HTML |
name: info
age: 62 | name: info
age: 62 | Correct. | YAML |
[90, 39, 100 | [90, 39, 100] | Close bracket. | Python |
for x in range(48)
print(x) | for x in range(48):
print(x) | Colon after for. | Python |
for (c in values) | for (c of values) | for...in iterates keys. | JavaScript |
data = 9 | data=9 | No spaces. | Shell |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
function foo() {{
return
{{key:'value'}}
}} | function foo() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
// comment | /* comment */ | Use /* */. | CSS |
class = 'output' | class_name = 'output' | 'class' is a keyword. | Python |
println('message') | println("message") | Double quotes. | Scala |
let foo: Int = 'hello' | let foo: String = 'hello' | Fix type. | Swift |
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 |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
fn foo() -> i32 {{ 64 }} | fn foo() -> i32 {{ 64 }} | Correct. | Rust |
{{'status':16, 'value' 40}} | {{'status':16, 'value':40}} | Colon missing. | Python |
let b = 10; b += 1; | let mut b = 10; b += 1; | Need mut to modify. | Rust |
<br></br> | <br> | Self-closing. | HTML |
SELECT * FROM orders WHRE status=56; | SELECT * FROM orders WHERE status=56; | Fix WHERE. | SQL |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
foo | foo() | Add parentheses. | Swift |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
class Order {{ int z; }}; | class Order {{ public: int z; }}; | Make public. | C++ |
with open('config.json') as f:
data = f.read() | with open('config.json') as f:
data = f.read() | Correct. | Python |
items[90] | if (items.indices.contains(90)) items[90] | Check index. | Kotlin |
if (b = 24) | if (b == 24) | Use ==. | Scala |
items[93] | if (length(items) >= 93) items[93] | Check length. | R |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
match val {{ 1 => {{}} }} | match val {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
z > 39 & z < 63 | z > 39 and z < 63 | Use 'and' not '&'. | Python |
print('value') | print('value') | Correct. | R |
let val: number = 'data'; | let val: string = 'data'; | Fix type. | TypeScript |
<table><tr><td>test<td>data</tr></table> | <table><tr><td>test</td><td>data</td></tr></table> | Close td. | HTML |
[64, 66, 48 | [64, 66, 48] | Close bracket. | Ruby |
let num: number | null = null; num.toFixed(30); | let num: number | null = null; if(num!==null) num.toFixed(30); | Null check. | TypeScript |
if (z = 100) {{}} | if (z == 100) {{}} | Use ==. | Java |
cin >> val; | int val;
cin >> val; | Declare variable. | C++ |
<input type='text' value='value'> | <input type='text' value='value' name='id'> | Add name attribute. | HTML |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
jwt.sign({{id:56}}, 'secret'); | jwt.sign({{id:56}}, 'secret', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
if [ $result = 81 ]; then | if [ "$result" = 81 ]; then | Quote variable. | Shell |
#footer {{ color: #fff; }} | #footer {{ color: #fff; }} | Correct. | CSS |
print 'test' | print('test') | print needs parentheses. | Python |
UPDATE users SET age='hello' WHERE role=26 | UPDATE users SET age='hello' WHERE role=26; | Add semicolon. | SQL |
SELECT name email FROM products; | SELECT name, email FROM products; | Add comma. | SQL |
let text1 = String::from("hello"); let s2 = text1; println!("{{}}", text1); | let text1 = String::from("hello"); let s2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
name: data
status: data, | name: data
status: data | Remove comma. | YAML |
$x = 31; if ($x = 31) {{}} | $x = 31; if ($x == 31) {{}} | Use ==. | PHP |
var x int | var x int | Correct. | Go |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
list[60] | if list.indices.contains(60) {{ list[60] }} | Check index. | Swift |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
'hello' + 40 | 'hello' + str(40) | Can't add int to string. | Python |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
if a = 75: | if a == 75: | Use == for comparison. | Python |
for i=1,18 do print(i) end | for i=1,18 do print(i) end | Correct. | Lua |
h1 {{ font-size:49px color:#333; }} | h1 {{ font-size:49px; color:#333; }} | Add semicolon. | CSS |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.