15
Summary on Javascript coding Document.write produces a message in a program, what is within the quotation marks will be displayed in the program for example- (“ the total marks are”)

Coding task new

Embed Size (px)

Citation preview

Page 1: Coding task new

Summary on Javascript coding

Document.write produces a message in a program, what is within the quotation marks will be displayed in the program for example-

(“ the total marks are”)

Page 2: Coding task new

Summary on Javascript coding

Variables can be defined with a name, any name you choose for example... var maroon_5

Variable names are case-sensitive and should only begin with a letter/underscore. Var 6num would not work.

Variables can not include spaces

Page 3: Coding task new

Summary on Javascript coding

ParseInt is used in coding to assign a variable to be recognised by the program. For example if you see numb=parseInt(numb) then this means that var numb will be a number you enter into the program.

Page 4: Coding task new

Summary on Javascript coding

Mathematical operators are used to make the program perform an equation on numerical data.

*, %, -, /, + are examples of operators.

Page 5: Coding task new

Summary on Javascript coding

Prompt is used to make the program allow the user to enter data.

Anything included in the quotation marks will displayed in the program. For example- var numb= prompt(“ enter a number here”);

Page 6: Coding task new

Summary on Javascript coding

Other Mathematical operators

== (is equal to)

< (is less than)

> (is more than)

<= (is less than equal to)

!= (is not equal to)

>= (is greater than equal to)

Page 7: Coding task new

Summary on Javascript coding The if statement allows the program to

provide more than one output If is always followed with { and } clauses Can include an else to add additonal outputs

based on the data for example-if( marks>3)

{

document.write (“yes”)

}

else

{

Document.write (“no”)

}

Page 8: Coding task new

Coding activity

Instructions-Choose one of the code statements in each slide

and copy into notepad to build a program

Page 9: Coding task new

Write a program to present the Grade for marks of a test

A) <html>

<body>

<script type="text/javascript">

b)<html>

<script ="text/javascript">

c)<html>

<body>

<script type="javascript">

Page 10: Coding task new

Grade for marks of a test

A)var marks = prompt(enter the marks of test)

marks=parseInt(result);

b)var marks = prompt("enter the marks of test","");

marks=parseInt(marks);

c)var result = ("enter the marks of test","");

totalmarks=parseInt(marks);

Page 11: Coding task new

Grade for marks of a test

A)if else(marks==60)

{

document.write("grade is a");

b)if(marks>=60)

{

Documentwrite=("grade is a");

c)if(marks>=60)

{

document.write("grade is a");

Page 12: Coding task new

Grade for marks of a test

A) }

Else = (marks >=45)

{

document.write("grade is b");

b) }

else if (marks =45)

{

document.write("grade is b");

c) }

else if (marks >=45)

{

document.write("grade is b");

Page 13: Coding task new

Grade for marks of a test

A) }

else if (marks >=30)

{

document.write("grade is c");

b) }

else if (marks >=30)

document.write("grade is c")

c) {

else if (marks >=30)

{

document.write("grade is c");

Page 14: Coding task new

Grade for marks of a test A) }

else

{

document.write("grade is f");

}

b)

else

{

document.write("grade is f");

}

c) }

else

{

document.write(grade is f);

}

Page 15: Coding task new

Grade for marks of a test A)<script>

</body>

</html>

b)

</body>

</html>

c)

</html>