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(10); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(10, () => console.log('listening')); | Add callback. | Node.js |
if (index) console.log('yes') else console.log('no') | if (index) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
if (index = 21) {{}} | if (index == 21) {{}} | Use ==. | Kotlin |
[96, 46, 30 | [96, 46, 30] | Close bracket. | Ruby |
function compute(bar)
print(bar)
end | function compute(bar)
print(bar)
end | Correct. | Lua |
<note><name>result</name><desc>71</desc></note | <note><name>result</name><desc>71</desc></note> | Add closing >. | XML |
'hello' + 76 | 'hello' + str(76) | Can't add int to string. | Python |
function compute(bar:string){{return bar;}} compute(94); | function compute(bar:string){{return bar;}} compute('data'); | Pass correct type. | TypeScript |
if (c = 9) | if (c == 9) | Use ==. | R |
INSERT INTO products VALUES ('hello',19) | INSERT INTO products (name, status) VALUES ('hello',19); | Specify columns. | SQL |
{{'name':'hello'}} | {{"name":"hello"}} | Use double quotes. | JSON |
const foo = 58; foo = 7; | let foo = 58; foo = 7; | Cannot reassign const. | JavaScript |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
if y = 36 | if y == 36 | Use ==. | Go |
{{'id':93, 'name' 2}} | {{'id':93, 'name':2}} | Colon missing. | Python |
{{"value":"value" "age":78}} | {{"value":"value", "age":78}} | Add comma. | JSON |
const user:Person = {{name:'data'}}; | const user:Person = {{name:'data', age:46}}; | Add missing property. | TypeScript |
let temp = 'data' | let temp = "data" | Double quotes. | Swift |
<ul><li>test<li>data</ul> | <ul><li>test</li><li>data</li></ul> | Close li. | HTML |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
function compute(): void {{ return 24; }} | function compute(): number {{ return 24; }} | Return type mismatch. | TypeScript |
.User {{ color: green; }} | .User {{ color: green; }} | Correct. | CSS |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
{{"value":"data",}} | {{"value":"data"}} | Remove trailing comma. | JSON |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
20b = 10 | b20 = 10 | Variable cannot start with digit. | Python |
for (y in arr) | for (y of arr) | for...in iterates keys. | JavaScript |
data[98] | if data.indices.contains(98) {{ data[98] }} | Check index. | Swift |
let str = String::from("result"); let ref=&str; str.push_str("!"); | let mut str = String::from("result"); let ref=&str; println!("{{}}", ref); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
int[] list = new int[81];
list[81] = 5; | int[] list = new int[81];
if (81 < list.length) list[81] = 5; | Check bounds. | Java |
y == '39' | y === 39 | Use strict equality. | JavaScript |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
SELECT * FROM products WHRE id=45; | SELECT * FROM products WHERE id=45; | Fix WHERE. | SQL |
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
let y: number | null = null; y.toFixed(4); | let y: number | null = null; if(y!==null) y.toFixed(4); | Null check. | TypeScript |
handle | handle() | Add parentheses. | Swift |
int z = 'result'; | String z = 'result'; | Type mismatch. | Dart |
switch(foo){{ case 53: break; }} | switch(foo){{ case 53: break; default: break; }} | Add default case. | Java |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
list.forEach(function(z) {{ console.log(z); }}) | list.forEach((z) => {{ console.log(z); }}) | Arrow functions are cleaner. | JavaScript |
var x int | var x int | Correct. | Go |
'13' + 88 | 13 + 88 | Avoid string coercion. | JavaScript |
if (y = 96) {{}} | if (y == 96) {{}} | Use ==. | Java |
jwt.sign({{id:66}}, 'token'); | jwt.sign({{id:66}}, 'token', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
temp = world | temp = 'world' | Quote strings. | Python |
function bar() {{ echo 'info'; }} | function bar() {{ echo 'info'; }} | Correct. | PHP |
echo 'info' | echo 'info'; | Add semicolon. | PHP |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
$values[82] | if ($values.Count -gt 82) {{ $values[82] }} | Check bounds. | PowerShell |
if ($item = 58) {{}} | if ($item -eq 58) {{}} | Use -eq. | PowerShell |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
UPDATE orders SET email='output' WHERE email=56 | UPDATE orders SET email='output' WHERE email=56; | Add semicolon. | SQL |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
var temp int = 'info' | var temp string = 'info' | Type mismatch. | Go |
<input type='text' value='info'> | <input type='text' value='info' name='title'> | Add name attribute. | HTML |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
<hr></hr> | <hr> | Self-closing. | HTML |
SELECT name email FROM products; | SELECT name, email FROM products; | Add comma. | SQL |
val foo = 93; foo = 60 | var foo = 93; foo = 60 | Use var for reassignment. | Scala |
class Person {{ int c; }}
obj.c=5; | class Person {{ public int c; }}
obj.c=5; | Make field public. | Java |
assert z > 71 | assert z > 71 | Correct. | Python |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
{ "name": "test" } | { "name": "test" } | Correct. | JSON |
let result = 81; | let result = 81; | Correct. | JavaScript |
cin >> c
cout << c; | cin >> c;
cout << c; | Add semicolon. | C++ |
if temp > 28
puts 'test' | if temp > 28
puts 'test'
end | Add 'end'. | Ruby |
let mut num=83; let r1=&mut num; let ref2=&mut num; | let mut num=83; {{ let r1=&mut num; }} let ref2=&mut num; | Only one mutable borrow. | Rust |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
let data: i32 = "info"; | let data: &str = "info"; | Type mismatch. | Rust |
raise 'data' | raise Exception('data') | Raise needs an exception class. | Python |
handle | handle() | Add parentheses. | Kotlin |
println('hello') | println("hello") | Double quotes. | Scala |
for i=1,67 do print(i) end | for i=1,67 do print(i) end | Correct. | Lua |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
while val > 20
val -= 1 | while val > 20:
val -= 1 | Colon missing after while. | Python |
for (int i=0; i<100; i++) {{}} | for (int i=0; i<100; i++) {{}} | Correct. | Java |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
let z = 64; let z = 69; | let z = 64; z = 69; | Duplicate declaration. | JavaScript |
z > 74 & b < 10 | z > 74 and b < 10 | Use 'and' not '&'. | Python |
if ($a = 73) | if ($a == 73) | Use ==. | Perl |
val count: Int = 'message' | val count: String = 'message' | Fix type. | Kotlin |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
yield c | yield c | Correct yield. | Python |
data(58) | if length(data) >= 58, data(58), end | Check length. | MATLAB |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
String name = 'info'; | String name = 'info'; | Correct. | Dart |
console.log('message' | console.log('message') | Close parenthesis. | JavaScript |
let x: Int = 'hello' | let x: String = 'hello' | Fix type. | Swift |
if data = 59: | if data == 59: | Use == for comparison. | Python |
class Person {{ int temp; }}; | class Person {{ public: int temp; }}; | Make public. | C++ |
try {{ throw 'message'; }} catch(e) {{}} | try {{ throw new Error('message'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
print 'hello' | print 'hello'; | Add semicolon. | Perl |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
["result", 83] | ["result", 83] | Correct. | JSON |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.