wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
try {{ throw 'test'; }} catch(e) {{}} | try {{ throw new Error('test'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
function bar() {{
return
{{key:'result'}}
}} | function bar() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
// comment | /* comment */ | Use /* */. | CSS |
process | process() | Add parentheses. | Kotlin |
random.sqrt(32) | import random
random.sqrt(32) | Import module first. | Python |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
function compute() {{ echo 'output'; }} | function compute() {{ echo 'output'; }} | Correct. | PHP |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
.Order {{ color: red; }} | .Order {{ color: red; }} | Correct. | CSS |
let temp: number = 'message'; | let temp: string = 'message'; | Fix type. | TypeScript |
{{'value':23, 'value' 47}} | {{'value':23, 'value':47}} | Colon missing. | Python |
if [ $val = 44 ]; then | if [ "$val" = 44 ]; then | Quote variable. | Shell |
if result = 91 | if result == 91 | Use ==. | Go |
fn render() -> i32 {{ 77 }} | fn render() -> i32 {{ 77 }} | Correct. | Rust |
for (x in data) | for (x of data) | for...in iterates keys. | JavaScript |
String z = 'world'; | String z = "world"; | Double quotes. | Java |
System.out.println('hello') | System.out.println('hello'); | Add semicolon. | Java |
match c {{ 1 => {{}} }} | match c {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
let str = String::from("output"); let borrow=&str; str.push_str("!"); | let mut str = String::from("output"); let borrow=&str; println!("{{}}", borrow); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
'data' + 64 | 'data' + str(64) | Can't add int to string. | Python |
<center>result</center> | <div style='text-align:center;'>result</div> | Use CSS. | HTML |
if (a = 49) | if (a == 49) | Use ==. | C++ |
process | process() | Add parentheses. | Swift |
list[29] | if (list.indices.contains(29)) list[29] | Check index. | Kotlin |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
function baz(result:string){{return result;}} baz(38); | function baz(result:string){{return result;}} baz('value'); | Pass correct type. | TypeScript |
my @arr = (71,55,13); | my @arr = (71,55,13); | Correct. | Perl |
if (c = 90) | if (c == 90) | Use ==. | R |
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }}); | fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
for (int i=0; i<45; i++) {{}} | for (int i=0; i<45; i++) {{}} | Correct. | Java |
[2, 42, 93 | [2, 42, 93] | Close bracket. | Python |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
<person><age>test</age><age>14</age></person | <person><age>test</age><age>14</age></person> | Add closing >. | XML |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
age: value
age: world, | age: value
age: world | Remove comma. | YAML |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
const temp; | const temp = 29; | Initialize const. | JavaScript |
disp('result') | disp('result') | Correct. | MATLAB |
class = 'output' | class_name = 'output' | 'class' is a keyword. | Python |
UPDATE orders SET age='message' WHERE email=97 | UPDATE orders SET age='message' WHERE email=97; | Add semicolon. | SQL |
if b = 74: | if b == 74: | Use == for comparison. | Python |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
assert y > 39 | assert y > 39 | Correct. | Python |
const person:Person = {{name:'info'}}; | const person:Person = {{name:'info', age:56}}; | Add missing property. | TypeScript |
print('message') | print('message') | Correct. | R |
temp = 22 | temp=22 | No spaces. | Shell |
values(47) | if length(values) >= 47, values(47), end | Check length. | MATLAB |
DELETE FROM orders WHERE age=1 | DELETE FROM orders WHERE age=1; | Add semicolon. | SQL |
if (num = 67) {{}} | if (num === 67) {{}} | Use === for equality. | JavaScript |
$data[40] = 5; | if (isset($data[40])) $data[40] = 5; | Check existence. | PHP |
$data[31] | if ($data.Count -gt 31) {{ $data[31] }} | Check bounds. | PowerShell |
#content {{ color: green; }} | #content {{ color: green; }} | Correct. | CSS |
if index > 75
print('world') | if index > 75:
print('world') | Colon missing after if. | Python |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
{{'value':'result'}} | {{"value":"result"}} | Use double quotes. | JSON |
let mut val=80; let r1=&mut val; let r2=&mut val; | let mut val=80; {{ let r1=&mut val; }} let r2=&mut val; | Only one mutable borrow. | Rust |
["world", 36] | ["world", 36] | Correct. | JSON |
6c = 10 | c6 = 10 | Variable cannot start with digit. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
print 'result' | print('result') | print needs parentheses. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
val index: Int = 'value' | val index: String = 'value' | Fix type. | Kotlin |
if temp = 91 | if temp == 91 | Use ==. | MATLAB |
<person name='data'/> | <person name="data"/> | Double quotes. | XML |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
void render();
int main(){{render();}} | void render(); // prototype
int main(){{render();}} | Declare before use. | C++ |
class Person {{ int temp; }}
obj.temp=5; | class Person {{ public int temp; }}
obj.temp=5; | Make field public. | Java |
echo message world | echo 'message world' | Quote to prevent splitting. | Shell |
<hr></hr> | <hr> | Self-closing. | HTML |
if (bar = 57) {{}} | if (bar == 57) {{}} | Use ==. | Kotlin |
<table><tr><td>test<td>world</tr></table> | <table><tr><td>test</td><td>world</td></tr></table> | Close td. | HTML |
def compute
puts 'data'
end | def compute
puts 'data'
end | Correct. | Ruby |
let num = 'info' | let num = "info" | Double quotes. | Swift |
cin >> foo
cout << foo; | cin >> foo;
cout << foo; | Add semicolon. | C++ |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
h1 {{ font-size:16px color:#333; }} | h1 {{ font-size:16px; color:#333; }} | Add semicolon. | CSS |
items.forEach(function(x) {{ console.log(x); }}) | items.forEach((x) => {{ console.log(x); }}) | Arrow functions are cleaner. | JavaScript |
<br></br> | <br> | Self-closing. | HTML |
x := 42 | x := 42 | Correct. | Go |
let list=vec![67,76,94]; let head=&list[0]; list.push(51); | let mut list=vec![67,76,94]; let head=list[0]; list.push(51); | Copy instead of reference. | Rust |
var x int = 'result' | var x string = 'result' | Type mismatch. | Go |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
if temp = 55 {{}} | if temp == 55 {{}} | Use ==. | Swift |
<p>result <b>hello</p></b> | <p>result <b>hello</b></p> | Nest properly. | HTML |
data[2] | if (length(data) >= 2) data[2] | Check length. | R |
INSERT INTO items VALUES ('value',8) | INSERT INTO items (age, email) VALUES ('value',8); | Specify columns. | SQL |
items[96] | if items.indices.contains(96) {{ items[96] }} | Check index. | Swift |
if data = 70 | if data == 70 | Use ==. | Ruby |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(11); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(11, () => console.log('listening')); | Add callback. | Node.js |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
WHERE age = '34' | WHERE age = 34 | Don't quote integer. | SQL |
cin >> result; | int result;
cin >> result; | Declare variable. | C++ |
def bar():
print('output') | def bar():
print('output') | Indent function body. | Python |
let a: i32 = "result"; | let a: &str = "result"; | Type mismatch. | Rust |
index == '33' | index === 33 | Use strict equality. | JavaScript |
val data = 'test' | val data = "test" | Double quotes. | Kotlin |
fmt.Println 'hello' | fmt.Println('hello') | Missing parentheses. | Go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.