wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
let result = 94; result += 1; | let mut result = 94; result += 1; | Need mut to modify. | Rust |
h1 {{ font-size:62px color:#333; }} | h1 {{ font-size:62px; color:#333; }} | Add semicolon. | CSS |
{{'value':77, 'name' 96}} | {{'value':77, 'name':96}} | Colon missing. | Python |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
val val = 'output' | val val = "output" | Double quotes. | Kotlin |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(40); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(40, () => console.log('listening')); | Add callback. | Node.js |
JOIN products ON items.id = products.status | JOIN products ON items.id = products.status | Correct. | SQL |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
<hr></hr> | <hr> | Self-closing. | HTML |
.Person {{ color: #333; }} | .Person {{ color: #333; }} | Correct. | CSS |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
<ul><li>hello<li>data</ul> | <ul><li>hello</li><li>data</li></ul> | Close li. | HTML |
print 'message' | print('message') | print needs parentheses. | Python |
<br></br> | <br> | Self-closing. | HTML |
SELECT age role FROM items; | SELECT age, role FROM items; | Add comma. | SQL |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
val x = 97; x = 79 | var x = 97; x = 79 | Use var for reassignment. | Scala |
const http = require('http'); http.createServer((req,res) => res.end('message')).listen(91); | const http = require('http'); http.createServer((req,res) => res.end('message')).listen(91); | Correct. | Node.js |
function baz(): void {{ return 39; }} | function baz(): number {{ return 39; }} | Return type mismatch. | TypeScript |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
random.sqrt(1) | import random
random.sqrt(1) | Import module first. | Python |
if ($index = 47) | if ($index == 47) | Use ==. | Perl |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
switch(temp){{ case 82: break; }} | switch(temp){{ case 82: break; default: break; }} | Add default case. | Java |
let b: number | null = null; b.toFixed(76); | let b: number | null = null; if(b!==null) b.toFixed(76); | Null check. | TypeScript |
void main() {{ print('output') }} | void main() {{ print('output'); }} | Add semicolon. | Dart |
for temp in range(66)
print(temp) | for temp in range(66):
print(temp) | Colon after for. | Python |
if (y = 57) {{}} | if (y == 57) {{}} | Use ==. | Java |
for (count in values) | for (count of values) | for...in iterates keys. | JavaScript |
DELETE FROM users WHERE status=28 | DELETE FROM users WHERE status=28; | Add semicolon. | SQL |
JOIN products ON users.id = products.id | JOIN products ON users.id = products.id | Correct. | SQL |
for (int i=0; i<81; i++) {{}} | for (int i=0; i<81; i++) {{}} | Correct. | Java |
println('info') | println("info") | Double quotes. | Scala |
const b = 55; b = 2; | let b = 55; b = 2; | Cannot reassign const. | JavaScript |
if result > 60
puts 'output' | if result > 60
puts 'output'
end | Add 'end'. | Ruby |
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 |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
if ($b = 13) {{}} | if ($b -eq 13) {{}} | Use -eq. | PowerShell |
if (val) console.log('yes') else console.log('no') | if (val) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
88count = 10 | count88 = 10 | Variable cannot start with digit. | Python |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
WHERE age = '77' | WHERE age = 77 | Don't quote integer. | SQL |
local y = 60 | local y = 60 | Correct. | Lua |
data[95] | if data.indices.contains(95) {{ data[95] }} | Check index. | Swift |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
String name = 'message'; | String name = 'message'; | Correct. | Dart |
if ($x = 27) | if ($x == 27) | Use ==. | Perl |
switch(data){{ case 31: break; }} | switch(data){{ case 31: break; default: break; }} | Add default case. | Java |
if num > 9
print('message') | if num > 9:
print('message') | Colon missing after if. | Python |
yield index | yield index | Correct yield. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
h1 {{ font-size:56px color:red; }} | h1 {{ font-size:56px; color:red; }} | Add semicolon. | CSS |
'93' + 21 | 93 + 21 | Avoid string coercion. | JavaScript |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
<hr></hr> | <hr> | Self-closing. | HTML |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if (val = 3) | if (val == 3) | Use ==. | R |
fmt.Println 'world' | fmt.Println('world') | Missing parentheses. | Go |
if (data = 23) | if (data == 23) | Use ==. | Scala |
let c: i32 = "test"; | let c: &str = "test"; | Type mismatch. | Rust |
let count = 61; let count = 15; | let count = 61; count = 15; | Duplicate declaration. | JavaScript |
jwt.sign({{id:16}}, 'secret'); | jwt.sign({{id:16}}, 'secret', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
c = 79 | c=79 | No spaces. | Shell |
class Item {{ int b; }}; | class Item {{ public: int b; }}; | Make public. | C++ |
["data", 18] | ["data", 18] | Correct. | JSON |
'world' + 56 | 'world' + str(56) | Can't add int to string. | Python |
if (a = 60) {} | if (a == 60) {} | Use ==. | Dart |
print 'data' | print('data') | print needs parentheses. | Python |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
<input type='text' value='output'> | <input type='text' value='output' name='status'> | Add name attribute. | HTML |
def process(data):
return data + 1 | def process(data):
return data + 1 | Correct. | Python |
num == '60' | num === 60 | Use strict equality. | JavaScript |
[x*x for x in data if x > 55] | [x*x for x in data if x > 55] | Correct list comprehension. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
if (foo = 19) {{}} | if (foo == 19) {{}} | Use ==. | Java |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
items.forEach(function(result) {{ console.log(result); }}) | items.forEach((result) => {{ console.log(result); }}) | Arrow functions are cleaner. | JavaScript |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
b > 51 & b < 66 | b > 51 and b < 66 | Use 'and' not '&'. | Python |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
echo value hello | echo 'value hello' | Quote to prevent splitting. | Shell |
List(51,94,90) | List(51,94,90) | Correct. | Scala |
let bar: number | null = null; bar.toFixed(44); | let bar: number | null = null; if(bar!==null) bar.toFixed(44); | Null check. | TypeScript |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
let y = 82; | let y = 82; | Correct. | JavaScript |
print('output') | print('output') | Correct. | R |
my @arr = (65,52,23); | my @arr = (65,52,23); | Correct. | Perl |
// comment | /* comment */ | Use /* */. | CSS |
if data = 43 then
print('test')
end | if data == 43 then
print('test')
end | Use ==. | Lua |
String a = 'info'; | String a = "info"; | Double quotes. | Java |
def baz
puts 'value'
end | def baz
puts 'value'
end | Correct. | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.