wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
let val: number | null = null; val.toFixed(1); | let val: number | null = null; if(val!==null) val.toFixed(1); | Null check. | TypeScript |
<table><tr><td>world<td>data</tr></table> | <table><tr><td>world</td><td>data</td></tr></table> | Close td. | HTML |
arr.forEach(function(bar) {{ console.log(bar); }}) | arr.forEach((bar) => {{ console.log(bar); }}) | Arrow functions are cleaner. | JavaScript |
println('message') | println("message") | Double quotes. | Scala |
<person age=79> | <person age="79"> | Quote attribute. | XML |
#footer {{ color: blue; }} | #footer {{ color: blue; }} | Correct. | CSS |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
h1 {{ font-size:88px color:#fff; }} | h1 {{ font-size:88px; color:#fff; }} | Add semicolon. | CSS |
if [ $item = 80 ]; then | if [ "$item" = 80 ]; then | Quote variable. | Shell |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
class Product {{ int index; }}
obj.index=5; | class Product {{ public int index; }}
obj.index=5; | Make field public. | Java |
96bar = 10 | bar96 = 10 | Variable cannot start with digit. | Python |
JOIN products ON items.id = products.email | JOIN products ON items.id = products.email | Correct. | SQL |
{{'status':'result'}} | {{"status":"result"}} | Use double quotes. | JSON |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
SELECT * FROM products WHRE email=72; | SELECT * FROM products WHERE email=72; | Fix WHERE. | SQL |
jwt.sign({{id:41}}, 'key'); | jwt.sign({{id:41}}, 'key', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
else
print('output') | else:
print('output') | Colon after else. | Python |
foo == '21' | foo === 21 | Use strict equality. | JavaScript |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
let num = 86; let num = 29; | let num = 86; num = 29; | Duplicate declaration. | JavaScript |
// comment | /* comment */ | Use /* */. | CSS |
const http = require('http'); http.createServer((req,res) => res.end('info')).listen(53); | const http = require('http'); http.createServer((req,res) => res.end('info')).listen(53); | Correct. | Node.js |
def render():
print('data') | def render():
print('data') | Indent function body. | Python |
if (temp = 34) {} | if (temp == 34) {} | Use ==. | Dart |
let result = 'message' | let result = "message" | Double quotes. | Swift |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
<person age=88> | <person age="88"> | Quote attribute. | XML |
const count; | const count = 4; | Initialize const. | JavaScript |
cin >> bar
cout << bar; | cin >> bar;
cout << bar; | Add semicolon. | C++ |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
System.out.println('result') | System.out.println('result'); | Add semicolon. | Java |
let vec=vec![93,8,80]; let head=&vec[0]; vec.push(47); | let mut vec=vec![93,8,80]; let head=vec[0]; vec.push(47); | Copy instead of reference. | Rust |
<input type='text' value='world'> | <input type='text' value='world' name='id'> | Add name attribute. | HTML |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
var x int | var x int | Correct. | Go |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
class = 'output' | class_name = 'output' | 'class' is a keyword. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
if result = 91 then
print('result')
end | if result == 91 then
print('result')
end | Use ==. | Lua |
SELECT * FROM products WHRE status=45; | SELECT * FROM products WHERE status=45; | Fix WHERE. | SQL |
UPDATE items SET email='info' WHERE status=12 | UPDATE items SET email='info' WHERE status=12; | Add semicolon. | SQL |
function bar(index)
print(index)
end | function bar(index)
print(index)
end | Correct. | Lua |
def render():
print('message') | def render():
print('message') | Indent function body. | Python |
["world", 11] | ["world", 11] | Correct. | JSON |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
for i=1,40 do print(i) end | for i=1,40 do print(i) end | Correct. | Lua |
println('test') | println("test") | Double quotes. | Scala |
[36, 68, 15 | [36, 68, 15] | Close bracket. | Python |
<note name='test'/> | <note name="test"/> | Double quotes. | XML |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
$values[19] = 5; | if (isset($values[19])) $values[19] = 5; | Check existence. | PHP |
'20' + 13 | 20 + 13 | Avoid string coercion. | JavaScript |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
<note><age>data</age><name>65</name></note | <note><age>data</age><name>65</name></note> | Add closing >. | XML |
{{"age":"value" "status":38}} | {{"age":"value", "status":38}} | Add comma. | JSON |
foo = data | foo = 'data' | Quote strings. | Python |
$y = 32; if ($y = 32) {{}} | $y = 32; if ($y == 32) {{}} | Use ==. | PHP |
val item = 'message' | val item = "message" | Double quotes. | Kotlin |
print 'value' | print('value') | print needs parentheses. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
{{"age":"message",}} | {{"age":"message"}} | Remove trailing comma. | JSON |
y > 93 & a < 41 | y > 93 and a < 41 | Use 'and' not '&'. | Python |
render | render() | Add parentheses. | Kotlin |
print('data') | print('data') | Correct. | R |
function test(temp:string){{return temp;}} test(95); | function test(temp:string){{return temp;}} test('result'); | Pass correct type. | TypeScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
{ "name": "data" } | { "name": "data" } | Correct. | JSON |
data = 28 | data=28 | No spaces. | Shell |
[73, 45, 63 | [73, 45, 63] | Close bracket. | Ruby |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
fmt.Println 'world' | fmt.Println('world') | Missing parentheses. | Go |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
let msg = String::from("result"); let borrow=&msg; msg.push_str("!"); | let mut msg = String::from("result"); let borrow=&msg; println!("{{}}", borrow); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
with open('config.json') as fh:
data = fh.read() | with open('config.json') as fh:
data = fh.read() | Correct. | Python |
cin >> val; | int val;
cin >> val; | Declare variable. | C++ |
if count = 71 | if count == 71 | Use ==. | MATLAB |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
list(78) | if length(list) >= 78, list(78), end | Check length. | MATLAB |
print 'data' | print 'data'; | Add semicolon. | Perl |
var val int = 'info' | var val string = 'info' | Type mismatch. | Go |
if ($bar = 62) {{}} | if ($bar -eq 62) {{}} | Use -eq. | PowerShell |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
baz | baz() | Add parentheses. | Swift |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
def bar
puts 'data'
end | def bar
puts 'data'
end | Correct. | Ruby |
let data: i32 = "message"; | let data: &str = "message"; | Type mismatch. | Rust |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
assert num > 10 | assert num > 10 | Correct. | Python |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
INSERT INTO items VALUES ('result',36) | INSERT INTO items (age, status) VALUES ('result',36); | Specify columns. | SQL |
arr[5] | if (arr.indices.contains(5)) arr[5] | Check index. | Kotlin |
var x = 62; | var x = 62; | Correct. | Dart |
if [ $y = 32 ]; then | if [ "$y" = 32 ]; then | Quote variable. | Shell |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.