Errors in coding

9,107 views

Published on

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
9,107
On SlideShare
0
From Embeds
0
Number of Embeds
8,726
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Errors in coding

  1. 1. Finding errors in code To become better at coding we must learn to find errors in the code. There are several things to look for in particular. *remember that if the code is missing one small then it will not work.
  2. 2. Semi-colon;  Always make sure a semi-colon is at the end of a statement for example-  document.write("grade is a");  numb1=parseInt(numb1);
  3. 3. Upper case and lower case  Words used must be identical or will not work, for example-  numb1=parseInt(NUMB3); (wont work)  numb1=parseInt(numb1); will work
  4. 4. Open and closing tags </>   You must ensure you close the html, body and script tags for the code to work, for example</html> </body> </script>
  5. 5. Quotation marks “”    Quotation marks must be in the () brackets when there is a word/sentence to be displayed for examplevar marks = prompt("enter the marks of test",""); (will work) var marks = prompt(enter the marks of test,); (won't work)
  6. 6. Copy the following codes into notepad and fix to make work <html><body><script type="text/javascript"> var marks = prompt("enter the marks of test",""); marks=(marks); if(marks=60) { document.write("grade is a") } else ^ (marks >=45) { document.write("grade is b }
  7. 7. Continued... else if(marks >=30) { document.write(grade is c") } else ^ document.write("grade is f"); } </script> </body>
  8. 8. <html> <script type="text/javascript"> var numb= prompt(enter a number to find it's square root") numb=parseInt(); var Result=numb*numb document.write("The square root is" , Result); </script> <body> </html>
  9. 9.  <html>  <body>  <script type="text/javascript">    var numb1=prompt("enter the adjacent of triangle?") var numb^=prompt("enter the opposite of triangle?") var numb3=prompt("enter the longest side/hypotenuse of triangle?");  numb1=parseInt(NUMB)  numb2=parseInt(numb2);
  10. 10. Continued... numb3=parseInt(numb; var Result=(numb1*numb1+numb2*numb2!=numb3); ^ (Result^=numb3) { document.write (this is not right triangle"); } else { document.write ("this is right triangle"); }

×