wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
jwt.sign({{id:55}}, 'key'); | jwt.sign({{id:55}}, 'key', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
<person age=61> | <person age="61"> | Quote attribute. | XML |
for (item in data) | for (item of data) | for...in iterates keys. | JavaScript |
val item = 90; item = 50 | var item = 90; item = 50 | Use var for reassignment. | Scala |
if temp = 44: | if temp == 44: | Use == for comparison. | Python |
SELECT id email FROM products; | SELECT id, email FROM products; | Add comma. | SQL |
println('result') | println("result") | Double quotes. | Scala |
'15' + 97 | 15 + 97 | Avoid string coercion. | JavaScript |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(71); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(71, () => console.log('listening')); | Add callback. | Node.js |
h1 {{ font-size:12px color:green; }} | h1 {{ font-size:12px; color:green; }} | Add semicolon. | CSS |
class User {{ int x; }}
obj.x=5; | class User {{ public int x; }}
obj.x=5; | Make field public. | Java |
if (z) console.log('yes') else console.log('no') | if (z) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
if (index = 64) | if (index == 64) | Use ==. | Scala |
if (c = 70) | if (c == 70) | Use ==. | R |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
yield z | yield z | Correct yield. | Python |
SELECT * FROM products WHRE name=56; | SELECT * FROM products WHERE name=56; | Fix WHERE. | SQL |
{{'status':'data'}} | {{"status":"data"}} | Use double quotes. | JSON |
with open('data.txt') as fp:
data = fp.read() | with open('data.txt') as fp:
data = fp.read() | Correct. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
num = 8 | num=8 | No spaces. | Shell |
print 'message' | print('message') | print needs parentheses. | Python |
local y = 84 | local y = 84 | Correct. | Lua |
val y = 'data' | val y = "data" | Double quotes. | Kotlin |
int temp = 'hello'; | String temp = 'hello'; | Type mismatch. | Dart |
let mut x=54; let ref1=&mut x; let ref2=&mut x; | let mut x=54; {{ let ref1=&mut x; }} let ref2=&mut x; | Only one mutable borrow. | Rust |
<p>result <b>test</p></b> | <p>result <b>test</b></p> | Nest properly. | HTML |
if ($index = 20) {{}} | if ($index -eq 20) {{}} | Use -eq. | PowerShell |
temp == '45' | temp === 45 | Use strict equality. | JavaScript |
$arr[2] | if ($arr.Count -gt 2) {{ $arr[2] }} | Check bounds. | PowerShell |
object User {{ def main(args: Array[String]) = println("data") }} | object User {{ def main(args: Array[String]): Unit = println("data") }} | Add return type Unit. | Scala |
handle | handle() | Add parentheses. | Swift |
SELECT * FROM users WHRE email=58; | SELECT * FROM users WHERE email=58; | Fix WHERE. | SQL |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
values[81] | if (length(values) >= 81) values[81] | Check length. | R |
int data[83]; data[83]=5; | int data[83]; if(83<83){{}} else data[83]=5; | Bounds check. | C++ |
while c > 92
c -= 1 | while c > 92:
c -= 1 | Colon missing after while. | Python |
INSERT INTO users VALUES ('message',79) | INSERT INTO users (age, status) VALUES ('message',79); | Specify columns. | SQL |
<hr></hr> | <hr> | Self-closing. | HTML |
int a = 'result'; | String a = 'result'; | Type mismatch. | Dart |
val y = 87; y = 10 | var y = 87; y = 10 | Use var for reassignment. | Scala |
class Item {{ int temp; }}; | class Item {{ public: int temp; }}; | Make public. | C++ |
function test() {{ echo 'data'; }} | function test() {{ echo 'data'; }} | Correct. | PHP |
'52' + 43 | 52 + 43 | Avoid string coercion. | JavaScript |
bar = 93 | bar=93 | No spaces. | Shell |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
if (data = 73) {{}} | if (data == 73) {{}} | Use ==. | Kotlin |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
if y = 32 | if y == 32 | Use ==. | MATLAB |
name: message
age: 6 | name: message
age: 6 | Correct. | YAML |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
a = info | a = 'info' | Quote strings. | Python |
String result = 'result'; | String result = "result"; | Double quotes. | Java |
let z: Int = 'test' | let z: String = 'test' | Fix type. | Swift |
// comment | /* comment */ | Use /* */. | CSS |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
my @arr = (1,3,40); | my @arr = (1,3,40); | Correct. | Perl |
if ($a = 86) | if ($a == 86) | Use ==. | Perl |
#main {{ color: #fff; }} | #main {{ color: #fff; }} | Correct. | CSS |
cin >> z
cout << z; | cin >> z;
cout << z; | Add semicolon. | C++ |
else
print('test') | else:
print('test') | Colon after else. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
if (num = 100) | if (num == 100) | Use ==. | Scala |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
const user:Person = {{name:'world'}}; | const user:Person = {{name:'world', age:14}}; | Add missing property. | TypeScript |
<entry name='world'/> | <entry name="world"/> | Double quotes. | XML |
SELECT age email FROM orders; | SELECT age, email FROM orders; | Add comma. | SQL |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
const data; | const data = 20; | Initialize const. | JavaScript |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
var x = 58; | var x = 58; | Correct. | Dart |
JOIN profiles ON orders.id = profiles.id | JOIN profiles ON orders.id = profiles.id | Correct. | SQL |
function test() {{
return
{{key:'output'}}
}} | function test() {{
return {{key:'output'}};
}} | Return object on same line. | JavaScript |
const y = 11; y = 76; | let y = 11; y = 76; | Cannot reassign const. | JavaScript |
{ "name": "info" } | { "name": "info" } | Correct. | JSON |
print 'hello' | print('hello') | print needs parentheses. | Python |
function process(count:string){{return count;}} process(12); | function process(count:string){{return count;}} process('message'); | Pass correct type. | TypeScript |
compute | compute() | Add parentheses. | Kotlin |
x := 75 | x := 75 | Correct. | Go |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
DELETE FROM orders WHERE age=92 | DELETE FROM orders WHERE age=92; | Add semicolon. | SQL |
result == '96' | result === 96 | Use strict equality. | JavaScript |
var x int | var x int | Correct. | Go |
<p>test <b>data</p></b> | <p>test <b>data</b></p> | Nest properly. | HTML |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
<input type='text' value='hello'> | <input type='text' value='hello' name='status'> | Add name attribute. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.