wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if (c = 24) | if (c == 24) | Use ==. | Scala |
<p>result <b>world</p></b> | <p>result <b>world</b></p> | Nest properly. | HTML |
if (foo = 58) | if (foo == 58) | Use ==. | R |
function render() {{
return
{{key:'message'}}
}} | function render() {{
return {{key:'message'}};
}} | Return object on same line. | JavaScript |
arr.forEach(function(count) {{ console.log(count); }}) | arr.forEach((count) => {{ console.log(count); }}) | Arrow functions are cleaner. | JavaScript |
class Order {{ int foo; }}; | class Order {{ public: int foo; }}; | Make public. | C++ |
<person><name>test</name><age>81</age></person | <person><name>test</name><age>81</age></person> | Add closing >. | XML |
name: value
name: hello, | name: value
name: hello | Remove comma. | YAML |
if b = 42 | if b == 42 | Use ==. | Ruby |
if (a = 65) | if (a == 65) | Use ==. | C++ |
data(74) | if length(data) >= 74, data(74), end | Check length. | MATLAB |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
if c > 53
print('world') | if c > 53:
print('world') | Colon missing after if. | Python |
val count: Int = 'result' | val count: String = 'result' | Fix type. | Kotlin |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
jwt.sign({{id:44}}, 'token'); | jwt.sign({{id:44}}, 'token', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
function baz() {{ echo 'hello'; }} | function baz() {{ echo 'hello'; }} | Correct. | PHP |
let item: number = 'hello'; | let item: string = 'hello'; | Fix type. | TypeScript |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
if index = 32 then
print('world')
end | if index == 32 then
print('world')
end | Use ==. | Lua |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
<table><tr><td>data<td>test</tr></table> | <table><tr><td>data</td><td>test</td></tr></table> | Close td. | HTML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
print 'result' | print 'result'; | Add semicolon. | Perl |
let x: Int = 'message' | let x: String = 'message' | Fix type. | Swift |
count == '17' | count === 17 | Use strict equality. | JavaScript |
$list[49] = 5; | if (isset($list[49])) $list[49] = 5; | Check existence. | PHP |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
var x int | var x int | Correct. | Go |
if (item = 68) {{}} | if (item == 68) {{}} | Use ==. | Kotlin |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if y = 39 | if y == 39 | Use ==. | Ruby |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
44a = 10 | a44 = 10 | Variable cannot start with digit. | Python |
let y = 33; let y = 45; | let y = 33; y = 45; | Duplicate declaration. | JavaScript |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
items.forEach(function(data) {{ console.log(data); }}) | items.forEach((data) => {{ console.log(data); }}) | Arrow functions are cleaner. | JavaScript |
raise 'data' | raise Exception('data') | Raise needs an exception class. | Python |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
yield x | yield x | Correct yield. | Python |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
JOIN products ON products.id = products.name | JOIN products ON products.id = products.name | Correct. | SQL |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
h1 {{ font-size:11px color:#fff; }} | h1 {{ font-size:11px; color:#fff; }} | Add semicolon. | CSS |
for foo in range(70)
print(foo) | for foo in range(70):
print(foo) | Colon after for. | Python |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
<hr></hr> | <hr> | Self-closing. | HTML |
random.sqrt(98) | import random
random.sqrt(98) | Import module first. | Python |
'78' + 48 | 78 + 48 | Avoid string coercion. | JavaScript |
let result = 18; result += 1; | let mut result = 18; result += 1; | Need mut to modify. | Rust |
let count = 'test' | let count = "test" | Double quotes. | Swift |
SELECT name status FROM orders; | SELECT name, status FROM orders; | Add comma. | SQL |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(40); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(40, () => console.log('listening')); | Add callback. | Node.js |
if y > 10
print('data') | if y > 10:
print('data') | Colon missing after if. | Python |
{{'title':'output'}} | {{"title":"output"}} | Use double quotes. | JSON |
void main() {{ print('hello') }} | void main() {{ print('hello'); }} | Add semicolon. | Dart |
function compute(): void {{ return 30; }} | function compute(): number {{ return 30; }} | Return type mismatch. | TypeScript |
compute | compute() | Add parentheses. | Swift |
#content {{ color: #fff; }} | #content {{ color: #fff; }} | Correct. | CSS |
while val > 1
val -= 1 | while val > 1:
val -= 1 | Colon missing after while. | Python |
arr[69] | if (length(arr) >= 69) arr[69] | Check length. | R |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
local item = 76 | local item = 76 | Correct. | Lua |
cin >> data
cout << data; | cin >> data;
cout << data; | Add semicolon. | C++ |
WHERE age = '94' | WHERE age = 94 | Don't quote integer. | SQL |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if ($z = 100) {{}} | if ($z -eq 100) {{}} | Use -eq. | PowerShell |
const a; | const a = 37; | Initialize const. | JavaScript |
let item: Int = 'world' | let item: String = 'world' | Fix type. | Swift |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
{ "name": "message" } | { "name": "message" } | Correct. | JSON |
function render() {{
return
{{key:'message'}}
}} | function render() {{
return {{key:'message'}};
}} | Return object on same line. | JavaScript |
.User {{ color: blue; }} | .User {{ color: blue; }} | Correct. | CSS |
name: info
age: 97 | name: info
age: 97 | Correct. | YAML |
var bar int = 'message' | var bar string = 'message' | Type mismatch. | Go |
SELECT * FROM users WHRE age=4; | SELECT * FROM users WHERE age=4; | Fix WHERE. | SQL |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
int[] data = new int[96];
data[96] = 5; | int[] data = new int[96];
if (96 < data.length) data[96] = 5; | Check bounds. | Java |
disp('value') | disp('value') | Correct. | MATLAB |
if (y = 71) | if (y == 71) | Use ==. | C++ |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
match y {{ 1 => {{}} }} | match y {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
function compute() {{ echo 'test'; }} | function compute() {{ echo 'test'; }} | Correct. | PHP |
fs.readFile('data.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('data.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
cin >> data; | int data;
cin >> data; | Declare variable. | C++ |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
if (c = 92) | if (c == 92) | Use ==. | R |
const http = require('http'); http.createServer((req,res) => res.end('value')).listen(77); | const http = require('http'); http.createServer((req,res) => res.end('value')).listen(77); | Correct. | Node.js |
val z = 3; z = 97 | var z = 3; z = 97 | Use var for reassignment. | Scala |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.