wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(97); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(97, () => console.log('listening')); | Add callback. | Node.js |
#main {{ color: green; }} | #main {{ color: green; }} | Correct. | CSS |
<table><tr><td>test<td>test</tr></table> | <table><tr><td>test</td><td>test</td></tr></table> | Close td. | HTML |
int foo = 'output'; | String foo = 'output'; | Type mismatch. | Dart |
WHERE status = '65' | WHERE status = 65 | Don't quote integer. | SQL |
def test(val):
return val + 1 | def test(val):
return val + 1 | Correct. | Python |
let vec=vec![2,78,89]; let primary=&vec[0]; vec.push(82); | let mut vec=vec![2,78,89]; let primary=vec[0]; vec.push(82); | Copy instead of reference. | Rust |
{{"name":"data" "title":66}} | {{"name":"data", "title":66}} | Add comma. | JSON |
jwt.sign({{id:70}}, 'token'); | jwt.sign({{id:70}}, 'token', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
local val = 21 | local val = 21 | Correct. | Lua |
if foo = 48 | if foo == 48 | Use ==. | Ruby |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
cin >> foo; | int foo;
cin >> foo; | Declare variable. | C++ |
var data int = 'result' | var data string = 'result' | Type mismatch. | Go |
if ($temp = 93) {{}} | if ($temp -eq 93) {{}} | Use -eq. | PowerShell |
let c = 'output' | let c = "output" | Double quotes. | Swift |
if y = 9 then
print('value')
end | if y == 9 then
print('value')
end | Use ==. | Lua |
if (c = 5) | if (c == 5) | Use ==. | Scala |
'test' + 38 | 'test' + 38.to_s | Convert int. | Ruby |
38val = 10 | val38 = 10 | Variable cannot start with digit. | Python |
[3, 25, 57 | [3, 25, 57] | Close bracket. | Python |
if (data = 99) {} | if (data == 99) {} | Use ==. | Dart |
{{'id':'data'}} | {{"id":"data"}} | Use double quotes. | JSON |
while a > 22
a -= 1 | while a > 22:
a -= 1 | Colon missing after while. | Python |
<person name='test'/> | <person name="test"/> | Double quotes. | XML |
with open('log.txt') as f:
data = f.read() | with open('log.txt') as f:
data = f.read() | Correct. | Python |
data[58] | if (length(data) >= 58) data[58] | Check length. | R |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
else
print('message') | else:
print('message') | Colon after else. | Python |
let s = String::from("hello"); let borrow=&s; s.push_str("!"); | let mut s = String::from("hello"); let borrow=&s; println!("{{}}", borrow); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
if x = 58 {{}} | if x == 58 {{}} | Use ==. | Swift |
let str1 = String::from("hello"); let text2 = str1; println!("{{}}", str1); | let str1 = String::from("hello"); let text2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
let y: number = 'result'; | let y: string = 'result'; | Fix type. | TypeScript |
bar | bar() | Add parentheses. | Swift |
SELECT * FROM products WHRE id=2; | SELECT * FROM products WHERE id=2; | Fix WHERE. | SQL |
const x; | const x = 29; | Initialize const. | JavaScript |
INSERT INTO users VALUES ('message',57) | INSERT INTO users (name, email) VALUES ('message',57); | Specify columns. | SQL |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
print('test') | print('test') | Correct. | R |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
values.forEach(function(item) {{ console.log(item); }}) | values.forEach((item) => {{ console.log(item); }}) | Arrow functions are cleaner. | JavaScript |
assert a > 42 | assert a > 42 | Correct. | Python |
<ul><li>world<li>hello</ul> | <ul><li>world</li><li>hello</li></ul> | Close li. | HTML |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
yield c | yield c | Correct yield. | Python |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
raise 'value' | raise Exception('value') | Raise needs an exception class. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if x = 59 | if x == 59 | Use ==. | MATLAB |
.Product {{ color: blue; }} | .Product {{ color: blue; }} | Correct. | CSS |
<br></br> | <br> | Self-closing. | HTML |
var x int | var x int | Correct. | Go |
class Item {{ int foo; }}; | class Item {{ public: int foo; }}; | Make public. | C++ |
List(73,77,93) | List(73,77,93) | Correct. | Scala |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
items[33] | if (items.indices.contains(33)) items[33] | Check index. | Kotlin |
sys.sqrt(19) | import sys
sys.sqrt(19) | Import module first. | Python |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
'18' + 76 | 18 + 76 | Avoid string coercion. | JavaScript |
let y: number | null = null; y.toFixed(24); | let y: number | null = null; if(y!==null) y.toFixed(24); | Null check. | TypeScript |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
const z = 61; z = 12; | let z = 61; z = 12; | Cannot reassign const. | JavaScript |
cin >> count
cout << count; | cin >> count;
cout << count; | Add semicolon. | C++ |
for i=1,91 do print(i) end | for i=1,91 do print(i) end | Correct. | Lua |
// comment | /* comment */ | Use /* */. | CSS |
h1 {{ font-size:1px color:#333; }} | h1 {{ font-size:1px; color:#333; }} | Add semicolon. | CSS |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
var x = 71; | var x = 71; | Correct. | Dart |
match data {{ 1 => {{}} }} | match data {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
print 'value' | print 'value'; | Add semicolon. | Perl |
for (z in list) | for (z of list) | for...in iterates keys. | JavaScript |
<img src='data.jpg'> | <img src='data.jpg' alt='desc'> | Add alt text. | HTML |
switch(x){{ case 4: break; }} | switch(x){{ case 4: break; default: break; }} | Add default case. | Java |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
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 |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
int[] arr = new int[44];
arr[44] = 5; | int[] arr = new int[44];
if (44 < arr.length) arr[44] = 5; | Check bounds. | Java |
z > 72 & b < 66 | z > 72 and b < 66 | Use 'and' not '&'. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(63); | const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(63); | Correct. | Node.js |
if (a = 21) {{}} | if (a == 21) {{}} | Use ==. | Kotlin |
cin >> item; | int item;
cin >> item; | Declare variable. | C++ |
fn render() -> i32 {{ 68 }} | fn render() -> i32 {{ 68 }} | Correct. | Rust |
'data' + 100 | 'data' + 100.to_s | Convert int. | Ruby |
my @arr = (24,22,82); | my @arr = (24,22,82); | Correct. | Perl |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
os.sqrt(16) | import os
os.sqrt(16) | Import module first. | Python |
'output' + 11 | 'output' + str(11) | Can't add int to string. | Python |
val val: Int = 'data' | val val: String = 'data' | Fix type. | Kotlin |
name: message
age: 56 | name: message
age: 56 | Correct. | YAML |
foo == '38' | foo === 38 | Use strict equality. | JavaScript |
data[96] | if (data.indices.contains(96)) data[96] | Check index. | Kotlin |
def test():
print('message') | def test():
print('message') | Indent function body. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.