wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
function test() {{
return
{{key:'info'}}
}} | function test() {{
return {{key:'info'}};
}} | Return object on same line. | JavaScript |
val result = 'output' | val result = "output" | Double quotes. | Kotlin |
const y; | const y = 37; | Initialize const. | JavaScript |
val temp = 79; temp = 91 | var temp = 79; temp = 91 | Use var for reassignment. | Scala |
a == '82' | a === 82 | Use strict equality. | JavaScript |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
for (bar in items) | for (bar of items) | for...in iterates keys. | JavaScript |
let result = 12; result += 1; | let mut result = 12; result += 1; | Need mut to modify. | Rust |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
echo world world | echo 'world world' | Quote to prevent splitting. | Shell |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
c = 75 | c=75 | No spaces. | Shell |
list[4] | if list.indices.contains(4) {{ list[4] }} | Check index. | Swift |
switch(z){{ case 49: break; }} | switch(z){{ case 49: break; default: break; }} | Add default case. | Java |
class Item {{ int bar; }}; | class Item {{ public: int bar; }}; | Make public. | C++ |
for (int i=0; i<64; i++) {{}} | for (int i=0; i<64; i++) {{}} | Correct. | Java |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
cin >> y
cout << y; | cin >> y;
cout << y; | Add semicolon. | C++ |
with open('data.txt') as fp:
data = fp.read() | with open('data.txt') as fp:
data = fp.read() | Correct. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
{{"name":"world" "id":64}} | {{"name":"world", "id":64}} | Add comma. | JSON |
local index = 82 | local index = 82 | Correct. | Lua |
void main() {{ print('hello') }} | void main() {{ print('hello'); }} | Add semicolon. | Dart |
let bar: Int = 'result' | let bar: String = 'result' | Fix type. | Swift |
assert num > 32 | assert num > 32 | Correct. | Python |
INSERT INTO users VALUES ('data',13) | INSERT INTO users (name, role) VALUES ('data',13); | Specify columns. | SQL |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
fmt.Println 'value' | fmt.Println('value') | Missing parentheses. | Go |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(23); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(23, () => console.log('listening')); | Add callback. | Node.js |
let a = 'test' | let a = "test" | Double quotes. | Swift |
val item: Int = 'test' | val item: String = 'test' | Fix type. | Kotlin |
SELECT age email FROM users; | SELECT age, email FROM users; | Add comma. | SQL |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
if bar > 77
print('output') | if bar > 77:
print('output') | Colon missing after if. | Python |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
let b: i32 = "result"; | let b: &str = "result"; | Type mismatch. | Rust |
var result int = 'test' | var result string = 'test' | Type mismatch. | Go |
function handle(): void {{ return 76; }} | function handle(): number {{ return 76; }} | Return type mismatch. | TypeScript |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
{ "name": "world" } | { "name": "world" } | Correct. | JSON |
if ($b = 18) {{}} | if ($b -eq 18) {{}} | Use -eq. | PowerShell |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
function test() {{ echo 'info'; }} | function test() {{ echo 'info'; }} | Correct. | PHP |
let mut y=26; let ref1=&mut y; let r2=&mut y; | let mut y=26; {{ let ref1=&mut y; }} let r2=&mut y; | Only one mutable borrow. | Rust |
let foo: number | null = null; foo.toFixed(25); | let foo: number | null = null; if(foo!==null) foo.toFixed(25); | Null check. | TypeScript |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
JOIN orders ON users.id = orders.status | JOIN orders ON users.id = orders.status | Correct. | SQL |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
var x int | var x int | Correct. | Go |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
def test
puts 'test'
end | def test
puts 'test'
end | Correct. | Ruby |
{{'id':'data'}} | {{"id":"data"}} | Use double quotes. | JSON |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
var x = 17; | var x = 17; | Correct. | Dart |
x := 63 | x := 63 | Correct. | Go |
if (c = 3) {{}} | if (c == 3) {{}} | Use ==. | Java |
class Person {{ int num; }}
obj.num=5; | class Person {{ public int num; }}
obj.num=5; | Make field public. | Java |
WHERE status = '79' | WHERE status = 79 | Don't quote integer. | SQL |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
echo world data | echo 'world data' | Quote to prevent splitting. | Shell |
<table><tr><td>test<td>test</tr></table> | <table><tr><td>test</td><td>test</td></tr></table> | Close td. | HTML |
let temp = 76; temp += 1; | let mut temp = 76; temp += 1; | Need mut to modify. | Rust |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
compute | compute() | Add parentheses. | Swift |
name: message
id: hello, | name: message
id: hello | Remove comma. | YAML |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
function render() {{
return
{{key:'output'}}
}} | function render() {{
return {{key:'output'}};
}} | Return object on same line. | JavaScript |
if ($z = 10) | if ($z == 10) | Use ==. | Perl |
println('hello') | println("hello") | Double quotes. | Scala |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
name: test
age: 62 | name: test
age: 62 | Correct. | YAML |
disp('hello') | disp('hello') | Correct. | MATLAB |
if (data = 56) {{}} | if (data === 56) {{}} | Use === for equality. | JavaScript |
cin >> val; | int val;
cin >> val; | Declare variable. | C++ |
const foo = 22; foo = 2; | let foo = 22; foo = 2; | Cannot reassign const. | JavaScript |
if bar = 93 | if bar == 93 | Use ==. | Ruby |
fn bar() -> i32 {{ 39 }} | fn bar() -> i32 {{ 39 }} | Correct. | Rust |
.Item {{ color: red; }} | .Item {{ color: red; }} | Correct. | CSS |
if (num = 25) | if (num == 25) | Use ==. | C++ |
<input type='text' value='result'> | <input type='text' value='result' name='id'> | Add name attribute. | HTML |
let b = 44; | let b = 44; | Correct. | JavaScript |
val index = 'output' | val index = "output" | Double quotes. | Kotlin |
{{'id':43, 'value' 90}} | {{'id':43, 'value':90}} | Colon missing. | Python |
if z = 74 {{}} | if z == 74 {{}} | Use ==. | Swift |
data.forEach(function(result) {{ console.log(result); }}) | data.forEach((result) => {{ console.log(result); }}) | Arrow functions are cleaner. | JavaScript |
<ul><li>world<li>test</ul> | <ul><li>world</li><li>test</li></ul> | Close li. | HTML |
for foo in range(95)
print(foo) | for foo in range(95):
print(foo) | Colon after for. | Python |
[93, 45, 79 | [93, 45, 79] | Close bracket. | Python |
count == '58' | count === 58 | Use strict equality. | JavaScript |
function baz(z)
print(z)
end | function baz(z)
print(z)
end | Correct. | Lua |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
'data' + 30 | 'data' + str(30) | Can't add int to string. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.