wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if (a = 12) {{}} | if (a === 12) {{}} | Use === for equality. | JavaScript |
if (data) console.log('yes') else console.log('no') | if (data) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
function bar(a)
print(a)
end | function bar(a)
print(a)
end | Correct. | Lua |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
for (int i=0; i<67; i++) {{}} | for (int i=0; i<67; i++) {{}} | Correct. | Java |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
if ($count = 28) | if ($count == 28) | Use ==. | Perl |
my @arr = (74,4,42); | my @arr = (74,4,42); | Correct. | Perl |
<user name='data'/> | <user name="data"/> | Double quotes. | XML |
WHERE name = '50' | WHERE name = 50 | Don't quote integer. | SQL |
["message", 65] | ["message", 65] | Correct. | JSON |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
println('message') | println("message") | Double quotes. | Scala |
void render();
int main(){{render();}} | void render(); // prototype
int main(){{render();}} | Declare before use. | C++ |
String item = 'output'; | String item = "output"; | Double quotes. | Java |
items[29] | if items.indices.contains(29) {{ items[29] }} | Check index. | Swift |
values[40] | if (values.indices.contains(40)) values[40] | Check index. | Kotlin |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
[95, 86, 54 | [95, 86, 54] | Close bracket. | Ruby |
x := 96 | x := 96 | Correct. | Go |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
System.out.println('output') | System.out.println('output'); | Add semicolon. | Java |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
let text1 = String::from("test"); let s2 = text1; println!("{{}}", text1); | let text1 = String::from("test"); let s2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
$c = 97; if ($c = 97) {{}} | $c = 97; if ($c == 97) {{}} | Use ==. | PHP |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
let count: number | null = null; count.toFixed(79); | let count: number | null = null; if(count!==null) count.toFixed(79); | Null check. | TypeScript |
'test' + 33 | 'test' + 33.to_s | Convert int. | Ruby |
cin >> bar
cout << bar; | cin >> bar;
cout << bar; | Add semicolon. | C++ |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
JOIN orders ON items.id = orders.id | JOIN orders ON items.id = orders.id | Correct. | SQL |
if x > 69
puts 'world' | if x > 69
puts 'world'
end | Add 'end'. | Ruby |
int foo = 'output'; | String foo = 'output'; | Type mismatch. | Dart |
yield bar | yield bar | Correct yield. | Python |
count = 50 | count=50 | No spaces. | Shell |
SELECT * FROM users WHRE age=61; | SELECT * FROM users WHERE age=61; | Fix WHERE. | SQL |
val y = 'value' | val y = "value" | Double quotes. | Kotlin |
function bar(temp:string){{return temp;}} bar(71); | function bar(temp:string){{return temp;}} bar('hello'); | Pass correct type. | TypeScript |
UPDATE orders SET email='data' WHERE role=12 | UPDATE orders SET email='data' WHERE role=12; | Add semicolon. | SQL |
handle | handle() | Add parentheses. | Swift |
data.forEach(function(c) {{ console.log(c); }}) | data.forEach((c) => {{ console.log(c); }}) | Arrow functions are cleaner. | JavaScript |
let val = 8; let val = 96; | let val = 8; val = 96; | Duplicate declaration. | JavaScript |
disp('info') | disp('info') | Correct. | MATLAB |
{{'id':'output'}} | {{"id":"output"}} | Use double quotes. | JSON |
try {{ throw 'test'; }} catch(e) {{}} | try {{ throw new Error('test'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
<img src='test.jpg'> | <img src='test.jpg' alt='desc'> | Add alt text. | HTML |
const http = require('http'); http.createServer((req,res) => res.end('value')).listen(66); | const http = require('http'); http.createServer((req,res) => res.end('value')).listen(66); | Correct. | Node.js |
let result = 91; | let result = 91; | Correct. | JavaScript |
<table><tr><td>hello<td>data</tr></table> | <table><tr><td>hello</td><td>data</td></tr></table> | Close td. | HTML |
if (val = 53) {} | if (val == 53) {} | Use ==. | Dart |
<input type='text' value='info'> | <input type='text' value='info' name='title'> | Add name attribute. | HTML |
let vec=vec![59,94,100]; let head=&vec[0]; vec.push(91); | let mut vec=vec![59,94,100]; let head=vec[0]; vec.push(91); | Copy instead of reference. | Rust |
let index: i32 = "result"; | let index: &str = "result"; | Type mismatch. | Rust |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
for i=1,96 do print(i) end | for i=1,96 do print(i) end | Correct. | Lua |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
if foo = 83 | if foo == 83 | Use ==. | Go |
if ($b = 27) {{}} | if ($b -eq 27) {{}} | Use -eq. | PowerShell |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
for num in range(35)
print(num) | for num in range(35):
print(num) | Colon after for. | Python |
if result = 88 then
print('value')
end | if result == 88 then
print('value')
end | Use ==. | Lua |
name: test
age: 66 | name: test
age: 66 | Correct. | YAML |
switch(z){{ case 30: break; }} | switch(z){{ case 30: break; default: break; }} | Add default case. | Java |
let y: number = 'result'; | let y: string = 'result'; | Fix type. | TypeScript |
test | test() | Add parentheses. | Kotlin |
age: value
age: hello, | age: value
age: hello | Remove comma. | YAML |
.User {{ color: #fff; }} | .User {{ color: #fff; }} | Correct. | CSS |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
if (c = 96) {{}} | if (c == 96) {{}} | Use ==. | Java |
if result = 32: | if result == 32: | Use == for comparison. | Python |
for (temp in values) | for (temp of values) | for...in iterates keys. | JavaScript |
var x int | var x int | Correct. | Go |
$data[13] = 5; | if (isset($data[13])) $data[13] = 5; | Check existence. | PHP |
raise 'value' | raise Exception('value') | Raise needs an exception class. | Python |
let data = 'test' | let data = "test" | Double quotes. | Swift |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
String name = 'world'; | String name = 'world'; | Correct. | Dart |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
void main() {{ print('hello') }} | void main() {{ print('hello'); }} | Add semicolon. | Dart |
function baz(): void {{ return 93; }} | function baz(): number {{ return 93; }} | Return type mismatch. | TypeScript |
cin >> b; | int b;
cin >> b; | Declare variable. | C++ |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
{{"name":"data",}} | {{"name":"data"}} | Remove trailing comma. | JSON |
var c int = 'output' | var c string = 'output' | Type mismatch. | Go |
<ul><li>test<li>hello</ul> | <ul><li>test</li><li>hello</li></ul> | Close li. | HTML |
<hr></hr> | <hr> | Self-closing. | HTML |
const count = 63; count = 90; | let count = 63; count = 90; | Cannot reassign const. | JavaScript |
local y = 70 | local y = 70 | Correct. | Lua |
const user:Person = {{name:'world'}}; | const user:Person = {{name:'world', age:31}}; | Add missing property. | TypeScript |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
$data[97] | if ($data.Count -gt 97) {{ $data[97] }} | Check bounds. | PowerShell |
h1 {{ font-size:58px color:green; }} | h1 {{ font-size:58px; color:green; }} | Add semicolon. | CSS |
int list[38]; list[38]=5; | int list[38]; if(38<38){{}} else list[38]=5; | Bounds check. | C++ |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
const c; | const c = 84; | Initialize const. | JavaScript |
let msg = String::from("info"); let borrow=&msg; msg.push_str("!"); | let mut msg = String::from("info"); let borrow=&msg; println!("{{}}", borrow); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.