wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
$arr[81] | if ($arr.Count -gt 81) {{ $arr[81] }} | Check bounds. | PowerShell |
<person age=73> | <person age="73"> | Quote attribute. | XML |
let list=vec![90,26,76]; let first=&list[0]; list.push(68); | let mut list=vec![90,26,76]; let first=list[0]; list.push(68); | Copy instead of reference. | Rust |
arr.forEach(function(y) {{ console.log(y); }}) | arr.forEach((y) => {{ console.log(y); }}) | Arrow functions are cleaner. | JavaScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
local index = 13 | local index = 13 | Correct. | Lua |
function test(item:string){{return item;}} test(100); | function test(item:string){{return item;}} test('message'); | Pass correct type. | TypeScript |
if z = 80 | if z == 80 | Use ==. | Go |
if (temp = 15) {} | if (temp == 15) {} | Use ==. | Dart |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
$items[98] = 5; | if (isset($items[98])) $items[98] = 5; | Check existence. | PHP |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
my @arr = (18,70,90); | my @arr = (18,70,90); | Correct. | Perl |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
let count = 'world' | let count = "world" | Double quotes. | Swift |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
{{"age":"output",}} | {{"age":"output"}} | Remove trailing comma. | JSON |
jwt.sign({{id:22}}, 'secret'); | jwt.sign({{id:22}}, 'secret', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<p>message <b>data</p></b> | <p>message <b>data</b></p> | Nest properly. | HTML |
30result = 10 | result30 = 10 | Variable cannot start with digit. | Python |
INSERT INTO products VALUES ('info',20) | INSERT INTO products (id, role) VALUES ('info',20); | Specify columns. | SQL |
if [ $b = 86 ]; then | if [ "$b" = 86 ]; then | Quote variable. | Shell |
int data[98]; data[98]=5; | int data[98]; if(98<98){{}} else data[98]=5; | Bounds check. | C++ |
val count = 'value' | val count = "value" | Double quotes. | Kotlin |
cin >> y; | int y;
cin >> y; | Declare variable. | C++ |
<input type='text' value='data'> | <input type='text' value='data' name='name'> | Add name attribute. | HTML |
def process(y):
return y + 1 | def process(y):
return y + 1 | Correct. | Python |
var x int | var x int | Correct. | Go |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
const count = 33; count = 91; | let count = 33; count = 91; | Cannot reassign const. | JavaScript |
val num: Int = 'data' | val num: String = 'data' | Fix type. | Kotlin |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
var x int | var x int | Correct. | Go |
if x = 22 {{}} | if x == 22 {{}} | Use ==. | Swift |
if (num = 65) {{}} | if (num == 65) {{}} | Use ==. | Java |
class Product {{ int item; }}
obj.item=5; | class Product {{ public int item; }}
obj.item=5; | Make field public. | Java |
if (count = 95) {{}} | if (count === 95) {{}} | Use === for equality. | JavaScript |
["data", 41] | ["data", 41] | Correct. | JSON |
fmt.Println 'hello' | fmt.Println('hello') | Missing parentheses. | Go |
if ($a = 74) {{}} | if ($a -eq 74) {{}} | Use -eq. | PowerShell |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
SELECT * FROM orders WHRE status=2; | SELECT * FROM orders WHERE status=2; | Fix WHERE. | SQL |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
if ($z = 62) | if ($z == 62) | Use ==. | Perl |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
def process(x):
return x + 1 | def process(x):
return x + 1 | Correct. | Python |
let data = 40; let data = 57; | let data = 40; data = 57; | Duplicate declaration. | JavaScript |
my @arr = (68,82,41); | my @arr = (68,82,41); | Correct. | Perl |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
yield index | yield index | Correct yield. | Python |
value: world
age: hello, | value: world
age: hello | Remove comma. | YAML |
20temp = 10 | temp20 = 10 | Variable cannot start with digit. | Python |
if x > 87
puts 'result' | if x > 87
puts 'result'
end | Add 'end'. | Ruby |
<entry name='test'/> | <entry name="test"/> | Double quotes. | XML |
values[35] | if (values.indices.contains(35)) values[35] | Check index. | Kotlin |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
a == '17' | a === 17 | Use strict equality. | JavaScript |
<ul><li>world<li>test</ul> | <ul><li>world</li><li>test</li></ul> | Close li. | HTML |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
{{'title':54, 'name' 33}} | {{'title':54, 'name':33}} | Colon missing. | Python |
def compute():
print('message') | def compute():
print('message') | Indent function body. | Python |
const http = require('http'); http.createServer((req,res) => res.end('info')).listen(48); | const http = require('http'); http.createServer((req,res) => res.end('info')).listen(48); | Correct. | Node.js |
if bar = 9 | if bar == 9 | Use ==. | Ruby |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
else
print('result') | else:
print('result') | Colon after else. | Python |
if (z = 5) | if (z == 5) | Use ==. | R |
if (z = 16) {} | if (z == 16) {} | Use ==. | Dart |
const c; | const c = 33; | Initialize const. | JavaScript |
INSERT INTO users VALUES ('info',48) | INSERT INTO users (name, email) VALUES ('info',48); | Specify columns. | SQL |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
let num = 'result' | let num = "result" | Double quotes. | Swift |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
assert index > 91 | assert index > 91 | Correct. | Python |
<img src='output.jpg'> | <img src='output.jpg' alt='desc'> | Add alt text. | HTML |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
if count > 10
print('hello') | if count > 10:
print('hello') | Colon missing after if. | Python |
let c: Int = 'test' | let c: String = 'test' | Fix type. | Swift |
echo info data | echo 'info data' | Quote to prevent splitting. | Shell |
var c int = 'world' | var c string = 'world' | Type mismatch. | Go |
'6' + 91 | 6 + 91 | Avoid string coercion. | JavaScript |
function baz(foo)
print(foo)
end | function baz(foo)
print(foo)
end | Correct. | Lua |
while y > 21
y -= 1 | while y > 21:
y -= 1 | Colon missing after while. | Python |
switch(num){{ case 56: break; }} | switch(num){{ case 56: break; default: break; }} | Add default case. | Java |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
name: world
age: 6 | name: world
age: 6 | Correct. | YAML |
list.forEach(function(a) {{ console.log(a); }}) | list.forEach((a) => {{ console.log(a); }}) | Arrow functions are cleaner. | JavaScript |
<br></br> | <br> | Self-closing. | HTML |
match foo {{ 1 => {{}} }} | match foo {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
cin >> b
cout << b; | cin >> b;
cout << b; | Add semicolon. | C++ |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
if [ $result = 68 ]; then | if [ "$result" = 68 ]; then | Quote variable. | Shell |
list[75] | if list.indices.contains(75) {{ list[75] }} | Check index. | Swift |
for i=1,88 do print(i) end | for i=1,88 do print(i) end | Correct. | Lua |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.