The document provides 3 code examples for JavaScript coding skills:
1. A code to find the square root of a number by prompting the user for input and using parseInt and Math functions.
2. A code to determine if a triangle is a right triangle by prompting the user for the sides and using an equation to check if it is a right triangle.
3. A code to get the grade from a test score by prompting the user and using if/else statements to return the grade based on the score.
1 of 7
Download to read offline
More Related Content
Code
1. Developing skills in coding
javascript
*Copy the following codes into notepad and
replace any of the ^ symbols to make the
code work correctly.
2. 1. To find the square root of a
number
<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>
3. 2.Finding out if a triangle is a
right triangle
So in Maths, if a2 +
b2 = c2 then the
triangle is a right
triangle.
4. <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);
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");
}
</script>
</body>
</html>
5. 3.Getting the grades from a test
score
<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");
}
else ^(marks >=30)
{
document.write("grade is c");
}
else
^
document.write("grade is f");
}
</script>
</body>
</html>
6. Writing javascript code
1.Create a program that when you enter a
number, it will be divided by 2.
* use the mathetical operator / to do this.
7. Writing javascript code
1.Create a program that when you enter a
number, it will be divided by 2.
* use the mathetical operator / to do this.