+ 4

Where is the mistake in this code?

<!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> <script type="text/javascript""> function add numbers() { var sum= firstnumber + secondnumber ; return sum; } var = addnumber (10,20); document.write(result); </script> </body> </html>

7th Jan 2018, 1:19 PM
James Ngai
James Ngai - avatar
3 Answers
+ 14
<!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> <script> function addNumbers(first, second) { let sum = first + second; return sum; } let test = addNumbers(10,20); document.write(result); </script> </body> </html> this should work post a link to the code next time
7th Jan 2018, 1:25 PM
Kamil
Kamil - avatar
+ 3
thanks
7th Jan 2018, 1:32 PM
James Ngai
James Ngai - avatar
0
<!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> <script type="text/javascript""> function addnumber(firstnumber,secondnumber) { var sum= firstnumber + secondnumber ; return sum; } var result = addnumber(10,20); document.write(result); </script> </body> </html> this one help me thanks
7th Jan 2018, 1:37 PM
James Ngai
James Ngai - avatar