wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
values.forEach(function(x) {{ console.log(x); }}) | values.forEach((x) => {{ console.log(x); }}) | Arrow functions are cleaner. | JavaScript |
if y > 60
print('hello') | if y > 60:
print('hello') | Colon missing after if. | Python |
bar = 5 | bar=5 | No spaces. | Shell |
function bar(count:string){{return count;}} bar(76); | function bar(count:string){{return count;}} bar('world'); | Pass correct type. | TypeScript |
test | test() | Add parentheses. | Swift |
if (temp = 20) {{}} | if (temp == 20) {{}} | Use ==. | Kotlin |
echo hello data | echo 'hello data' | Quote to prevent splitting. | Shell |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
if foo = 23 | if foo == 23 | Use ==. | MATLAB |
test | test() | Add parentheses. | Kotlin |
println('value') | println("value") | Double quotes. | Scala |
{{"status":"result",}} | {{"status":"result"}} | Remove trailing comma. | JSON |
void main() {{ print('test') }} | void main() {{ print('test'); }} | Add semicolon. | Dart |
if data = 30 | if data == 30 | Use ==. | Ruby |
print('data') | print('data') | Correct. | R |
name: test
age: 15 | name: test
age: 15 | Correct. | YAML |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
let num = 78; let num = 66; | let num = 78; num = 66; | Duplicate declaration. | JavaScript |
<person><name>test</name><name>87</name></person | <person><name>test</name><name>87</name></person> | Add closing >. | XML |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
let temp: number = 'output'; | let temp: string = 'output'; | Fix type. | TypeScript |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
with open('data.txt') as fh:
data = fh.read() | with open('data.txt') as fh:
data = fh.read() | Correct. | Python |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
SELECT * FROM orders WHRE id=3; | SELECT * FROM orders WHERE id=3; | Fix WHERE. | SQL |
'info' + 99 | 'info' + str(99) | Can't add int to string. | Python |
cin >> c; | int c;
cin >> c; | Declare variable. | C++ |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
if (data) console.log('yes') else console.log('no') | if (data) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
{ "name": "result" } | { "name": "result" } | Correct. | JSON |
'output' + 65 | 'output' + 65.to_s | Convert int. | Ruby |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(69); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(69, () => console.log('listening')); | Add callback. | Node.js |
print 'message' | print('message') | print needs parentheses. | Python |
def test():
print('result') | def test():
print('result') | Indent function body. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
83y = 10 | y83 = 10 | Variable cannot start with digit. | Python |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
// comment | /* comment */ | Use /* */. | CSS |
let x: number | null = null; x.toFixed(55); | let x: number | null = null; if(x!==null) x.toFixed(55); | Null check. | TypeScript |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
WHERE id = '64' | WHERE id = 64 | Don't quote integer. | SQL |
[x*x for x in data if x > 21] | [x*x for x in data if x > 21] | Correct list comprehension. | Python |
var x int | var x int | Correct. | Go |
const a; | const a = 98; | Initialize const. | JavaScript |
print 'info' | print 'info'; | Add semicolon. | Perl |
var val int = 'output' | var val string = 'output' | Type mismatch. | Go |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
$num = 65; if ($num = 65) {{}} | $num = 65; if ($num == 65) {{}} | Use ==. | PHP |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
y > 43 & b < 33 | y > 43 and b < 33 | Use 'and' not '&'. | Python |
const http = require('http'); http.createServer((req,res) => res.end('value')).listen(93); | const http = require('http'); http.createServer((req,res) => res.end('value')).listen(93); | Correct. | Node.js |
val index = 18; index = 81 | var index = 18; index = 81 | Use var for reassignment. | Scala |
const x = 6; x = 74; | let x = 6; x = 74; | Cannot reassign const. | JavaScript |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
data[81] | if (length(data) >= 81) data[81] | Check length. | R |
const person:Person = {{name:'data'}}; | const person:Person = {{name:'data', age:94}}; | Add missing property. | TypeScript |
yield y | yield y | Correct yield. | Python |
<p>data <b>test</p></b> | <p>data <b>test</b></p> | Nest properly. | HTML |
[44, 90, 86 | [44, 90, 86] | Close bracket. | Ruby |
val z = 'value' | val z = "value" | Double quotes. | Kotlin |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
let bar = 58; bar += 1; | let mut bar = 58; bar += 1; | Need mut to modify. | Rust |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
<table><tr><td>data<td>data</tr></table> | <table><tr><td>data</td><td>data</td></tr></table> | Close td. | HTML |
function baz(): void {{ return 68; }} | function baz(): number {{ return 68; }} | Return type mismatch. | TypeScript |
function compute(foo)
print(foo)
end | function compute(foo)
print(foo)
end | Correct. | Lua |
var x = 79; | var x = 79; | Correct. | Dart |
let vec=vec![4,37,13]; let primary=&vec[0]; vec.push(85); | let mut vec=vec![4,37,13]; let primary=vec[0]; vec.push(85); | Copy instead of reference. | Rust |
if num = 29 then
print('test')
end | if num == 29 then
print('test')
end | Use ==. | Lua |
else
print('info') | else:
print('info') | Colon after else. | Python |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
if bar = 65: | if bar == 65: | Use == for comparison. | Python |
for item in range(66)
print(item) | for item in range(66):
print(item) | Colon after for. | Python |
let temp = 70; | let temp = 70; | Correct. | JavaScript |
class Product {{ int item; }}
obj.item=5; | class Product {{ public int item; }}
obj.item=5; | Make field public. | Java |
let s1 = String::from("output"); let text2 = s1; println!("{{}}", s1); | let s1 = String::from("output"); let text2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
fn handle() -> i32 {{ 27 }} | fn handle() -> i32 {{ 27 }} | Correct. | Rust |
match b {{ 1 => {{}} }} | match b {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
$arr[96] = 5; | if (isset($arr[96])) $arr[96] = 5; | Check existence. | PHP |
my @arr = (79,49,29); | my @arr = (79,49,29); | Correct. | Perl |
if [ $temp = 3 ]; then | if [ "$temp" = 3 ]; then | Quote variable. | Shell |
#content {{ color: #fff; }} | #content {{ color: #fff; }} | Correct. | CSS |
function test() {{ echo 'value'; }} | function test() {{ echo 'value'; }} | Correct. | PHP |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(57); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(57, () => console.log('listening')); | Add callback. | Node.js |
for (int i=0; i<25; i++) {{}} | for (int i=0; i<25; i++) {{}} | Correct. | Java |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
jwt.sign({{id:27}}, 'secret'); | jwt.sign({{id:27}}, 'secret', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
math.sqrt(25) | import math
math.sqrt(25) | Import module first. | Python |
if a = 17 {{}} | if a == 17 {{}} | Use ==. | Swift |
if temp = 82 | if temp == 82 | Use ==. | MATLAB |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
let s1 = String::from("hello"); let str2 = s1; println!("{{}}", s1); | let s1 = String::from("hello"); let str2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
let val: Int = 'message' | let val: String = 'message' | Fix type. | Swift |
if z > 76
print('info') | if z > 76:
print('info') | Colon missing after if. | Python |
else
print('data') | else:
print('data') | Colon after else. | Python |
def process
puts 'result'
end | def process
puts 'result'
end | Correct. | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.