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('value')); app.listen(55); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(55, () => console.log('listening')); | Add callback. | Node.js |
x := 42 | x := 42 | Correct. | Go |
{ "name": "result" } | { "name": "result" } | Correct. | JSON |
values.forEach(function(foo) {{ console.log(foo); }}) | values.forEach((foo) => {{ console.log(foo); }}) | Arrow functions are cleaner. | JavaScript |
for (int i=0; i<35; i++) {{}} | for (int i=0; i<35; i++) {{}} | Correct. | Java |
const obj:Person = {{name:'test'}}; | const obj:Person = {{name:'test', age:31}}; | Add missing property. | TypeScript |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<br></br> | <br> | Self-closing. | HTML |
while data > 54
data -= 1 | while data > 54:
data -= 1 | Colon missing after while. | Python |
print('result') | print('result') | Correct. | R |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
bar | bar() | Add parentheses. | Swift |
["hello", 69] | ["hello", 69] | Correct. | JSON |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
<person name='world'/> | <person name="world"/> | Double quotes. | XML |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
<person age=15> | <person age="15"> | Quote attribute. | XML |
let count = 24; let count = 35; | let count = 24; count = 35; | Duplicate declaration. | JavaScript |
for val in range(22)
print(val) | for val in range(22):
print(val) | Colon after for. | Python |
var x = 25; | var x = 25; | Correct. | Dart |
if (data = 11) | if (data == 11) | Use ==. | Scala |
if x = 22 | if x == 22 | Use ==. | Go |
57c = 10 | c57 = 10 | Variable cannot start with digit. | Python |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
if a = 46 | if a == 46 | Use ==. | MATLAB |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
[x*x for x in arr if x > 36] | [x*x for x in arr if x > 36] | Correct list comprehension. | Python |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
{{"name":"info" "title":84}} | {{"name":"info", "title":84}} | Add comma. | JSON |
cin >> b; | int b;
cin >> b; | Declare variable. | C++ |
{{'status':80, 'age' 4}} | {{'status':80, 'age':4}} | Colon missing. | Python |
if x > 49
puts 'test' | if x > 49
puts 'test'
end | Add 'end'. | Ruby |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
if [ $index = 6 ]; then | if [ "$index" = 6 ]; then | Quote variable. | Shell |
assert count > 8 | assert count > 8 | Correct. | Python |
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 |
'36' + 63 | 36 + 63 | Avoid string coercion. | JavaScript |
my @arr = (89,25,3); | my @arr = (89,25,3); | Correct. | Perl |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
'value' + 40 | 'value' + 40.to_s | Convert int. | Ruby |
val z = 'value' | val z = "value" | Double quotes. | Kotlin |
value: output
age: test, | value: output
age: test | Remove comma. | YAML |
let count = 'hello' | let count = "hello" | Double quotes. | Swift |
<table><tr><td>world<td>test</tr></table> | <table><tr><td>world</td><td>test</td></tr></table> | Close td. | HTML |
println('info') | println("info") | Double quotes. | Scala |
let s1 = String::from("test"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("test"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
function process() {{ echo 'output'; }} | function process() {{ echo 'output'; }} | Correct. | PHP |
.Item {{ color: red; }} | .Item {{ color: red; }} | Correct. | CSS |
<br></br> | <br> | Self-closing. | HTML |
[x*x for x in arr if x > 70] | [x*x for x in arr if x > 70] | Correct list comprehension. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
let num = 78; num += 1; | let mut num = 78; num += 1; | Need mut to modify. | Rust |
name: data
age: 24 | name: data
age: 24 | Correct. | YAML |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
switch(item){{ case 91: break; }} | switch(item){{ case 91: break; default: break; }} | Add default case. | Java |
<person age=93> | <person age="93"> | Quote attribute. | XML |
if x > 96
puts 'value' | if x > 96
puts 'value'
end | Add 'end'. | Ruby |
yield a | yield a | Correct yield. | Python |
class User {{ int z; }}; | class User {{ public: int z; }}; | Make public. | C++ |
raise 'info' | raise Exception('info') | Raise needs an exception class. | Python |
let z: number = 'info'; | let z: string = 'info'; | Fix type. | TypeScript |
arr[48] | if (length(arr) >= 48) arr[48] | Check length. | R |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
h1 {{ font-size:97px color:green; }} | h1 {{ font-size:97px; color:green; }} | Add semicolon. | CSS |
INSERT INTO items VALUES ('output',41) | INSERT INTO items (id, email) VALUES ('output',41); | Specify columns. | SQL |
json.sqrt(23) | import json
json.sqrt(23) | Import module first. | Python |
num = output | num = 'output' | Quote strings. | Python |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
match x {{ 1 => {{}} }} | match x {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
echo test world | echo 'test world' | Quote to prevent splitting. | Shell |
if (a) console.log('yes') else console.log('no') | if (a) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
let num: Int = 'output' | let num: String = 'output' | Fix type. | Swift |
["test", 41] | ["test", 41] | Correct. | JSON |
if (foo = 86) {{}} | if (foo === 86) {{}} | Use === for equality. | JavaScript |
<p>output <b>test</p></b> | <p>output <b>test</b></p> | Nest properly. | HTML |
disp('value') | disp('value') | Correct. | MATLAB |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
function compute() {{
return
{{key:'info'}}
}} | function compute() {{
return {{key:'info'}};
}} | Return object on same line. | JavaScript |
void main() {{ print('value') }} | void main() {{ print('value'); }} | Add semicolon. | Dart |
let foo: i32 = "output"; | let foo: &str = "output"; | Type mismatch. | Rust |
[8, 70, 64 | [8, 70, 64] | Close bracket. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
<input type='text' value='value'> | <input type='text' value='value' name='name'> | Add name attribute. | HTML |
def render(num):
return num + 1 | def render(num):
return num + 1 | Correct. | Python |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
assert index > 85 | assert index > 85 | Correct. | Python |
local x = 40 | local x = 40 | Correct. | Lua |
let mut c=15; let r1=&mut c; let ref2=&mut c; | let mut c=15; {{ let r1=&mut c; }} let ref2=&mut c; | Only one mutable borrow. | Rust |
function bar(count)
print(count)
end | function bar(count)
print(count)
end | Correct. | Lua |
print 'hello' | print('hello') | print needs parentheses. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
[80, 37, 42 | [80, 37, 42] | Close bracket. | Ruby |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.