SlideShare a Scribd company logo
Programming in Java Script
Java Script
Programming Fundamentals
Java Script
• Programming language of the web
• Works in unison with HTML and CSS for web
page
• Code interpreted line by line by the javascript
engine built within web browser
Different from HTML & CSS
• HTML
– Structure of web page
• CSS
– Layout and Design
• Java Script
– Behaviour/Interaction
Use of JS
• Adds dynamic components
• Helps interaction with user
• Can be deferred loading
– Increases site speed
How to write JS code
• 2 ways of writing JS
– External file
– Embedded within HTML
Tags in HTML to embed JS
<script language="javascript">
.....js code....
</script>
JS embedded within HTML
<!DOCTYPE html>
<html>
<head>
<title>Today's Date</title>
<script>
let date1 = new Date();
alert("Today's date is " + date1);
</script>
</head>
<body>
</body>
</html>
Tags in HTML to link external JS
<!DOCTYPE html>
<html>
<head>
<title>Today's Date</title>
<script src="myscript.js"> </script>
</head>
<body>
<button type="button" onclick="firstFunction()">Check
Today's Date</button>
</body>
</html>
External JS
Code in myscript.js
function firstFunction()
{
let date1 = new Date();
alert("Today's date is " + date1);
}
Programming Fundamentals
3 Programming Basics
Program
• Series of instructions
• Input
• Process
• Output
• Instruction is given for every function
Programming
• Writing program in specific language
• Logically putting the solution together
• Breaking up solution into steps
• Writing instructions for every step
3 Programming Fundamentals
• Storage
• Conditional Constructs
• Iteration
Storage
• Save Data
• Input Data
– Data from user input
• Processed Data
– Data worked upon
• Output Data
– Message
Types of storage
• Variable
• Constants
• Arrays
Variables
• Named storage location in memory
• Holds a single value
• Value can change
Constants
• Named storage location in memory
• Holds a single value
• Value cannot change once assigned
Arrays
• Named storage location in memory
• Holds single or multiple values
• Value(s) can change
• Single array can contain one or more elements
• Each element has a value assigned to it
• All the elements of an array need to store values
of same data type
• Eg: int array of 5 elements will store 5 individual
values of integer type only. Cannot contain one
integer, one float, one string or any mix of it.
Conditional Constructs
• Applying Logic
– Yes-> Do this
– No-> Do that
• Black or White
• Zero or One
• Binary
• There is "No Grey Zone"
– If it is not yes or no then its an Error
If-Elseif-Else Ladder
• Check different options through permutations
and combinations
• Conditions depend on number of possible
options
• For checking different conditions use
appropriate operators
If
1. IF MARKS>40
PRINT:"Pass"
2. IF CHOICE=="Hunger Games"
PRINT:"Fiction"
If-else
1. IF MARKS>40
PRINT: "Pass"
ELSE
PRINT: "Fail"
2. IF CHOICE=="Hunger Games"
PRINT: "Fiction"
ELSE
PRINT: "Comedy"
If-elseif-else
1. IF MARKS>40
PRINT: "Pass"
ELSE IF MARKS==40
PRINT:"Just Pass"
ELSE
PRINT:"Fail"
2. IF CHOICE=="Hunger Games"
PRINT: "Fiction"
ELSE IF CHOICE=="Pride & Prejudice"
PRINT: "Classic"
ELSE
PRINT: "Comedy"
Operators
• Different conditions -> different operations
– Logical operators
– Arithmetic operators
– Relational operators
Relational
• To make a comparison while checking a
condition, use relational operators.
Operator Functionality Let’s consider x=5;
y=10;
> More Than x>y; False
< Less Than x<y; True
>= More Than or Equal
To
x>=y; False
<= Less Than or Equal
To
x<=y; True
== Equal to x==y; False
!= Not Equal to x!=y; True
Logical
• To combine two or more situations of
conditional checking use, logical operators.
Operator Functionality Condition
Example
&& Both the sides of
operator should
result true
x<y && y!=x True
x<y && y==x False
|| Either side of
operator should
result true
x<y || y!=x True
x<y || y!=x True
! Inverse the result x!<y
False
Arithmetic
• To compute arithmetic value we use
Arithmetic Operators.
Operator Functionality Condition
Example
+ Addition x+y 15
- Subtraction x-y -5
* Multiplication x*y 50
/ Division x/y 0
% Remainder x%y 5
Iteration
• Repetition of instructions
• Based on Logic
• Continue till condition is fulfilled
• Condition is not fulfilled-> stop processing &
break loop
• Move to line of code outside the loop
boundary
Types of loops
• For – Invariant check
• While – Pre-condition check
• Do-while – Post-condition check
For
• Steps
– Initialize
– Condition
– Process
– Increment/Decrement
BEGIN
INITIALISE vitaminc=0
FOR (int vitaminc=0; vitaminc<10; vitaminc++)
PRINT: "Vitamin C Added"
END FOR
PRINT: "Total amount of vitamin"+vitaminc
END
While
• Steps
– Initialize
– Condition
– Process
– Increment/decrement
BEGIN
INITIALISE choice="Orange"
INITIALIZE vitaminc=0
WHILE (choice=="Orange")
PRINT: "Vitamin C Added"
vitaminc++
GET: choice
END WHILE
PRINT: "Total amount of vitamin"+vitaminc
END
Do-While
• Steps
– Initialize
– Process
– Increment/Decrement
– Condition
BEGIN
INITIALISE choice=" "
INITIALISE vitaminc=0
DO
PRINT: "Vitamin C Added"
vitaminc++
GET: choice
WHILE(choice=="Orange")
PRINT: "Total amount of vitamin"+vitaminc
END
Basics of programming
https://www.codewizacademy.com
https://www.facebook.com/codewizacademy/
https://www.instagram.com/codewizacademy/

More Related Content

PPTX
Specificity and CSS Selectors
PPT
Asp #1
PPTX
Java script
PPTX
Regular Expressions
PPSX
Javascript variables and datatypes
PPTX
Javascript
PPTX
Matching with Regular Expressions
Specificity and CSS Selectors
Asp #1
Java script
Regular Expressions
Javascript variables and datatypes
Javascript
Matching with Regular Expressions

Similar to Programming fundamentals through javascript (20)

PPTX
JavaScript Session 2
PPSX
DIWE - Programming with JavaScript
PPT
Chaptfffffuuer05.PPT
PDF
Basic_C++ Notes with problema from Preethi arora and suneetha arora.pdf
PDF
Programming for Problem Solving
PPT
Introduction to javascript.ppt
PPTX
Lewis_Cocking_AP_Decision_Making_For_Coding
PDF
JavaScript for beginners
PPTX
PPTX
C programming slide c03
PPTX
Module2.2_Operators-in-C-Programming.pptx
PDF
learn basic to advance C Programming Notes
PDF
PPT
JavaScripttttttttttttttttttttttttttttttttttttttt.ppt
PDF
C++ problem solving operators ( conditional operators,logical operators, swit...
PPT
PPTX
Java script session 4
PPT
PPT
Data Structures- Part1 overview and review
PPTX
Java-Programming.forBSITSTUDENTfreespptx
JavaScript Session 2
DIWE - Programming with JavaScript
Chaptfffffuuer05.PPT
Basic_C++ Notes with problema from Preethi arora and suneetha arora.pdf
Programming for Problem Solving
Introduction to javascript.ppt
Lewis_Cocking_AP_Decision_Making_For_Coding
JavaScript for beginners
C programming slide c03
Module2.2_Operators-in-C-Programming.pptx
learn basic to advance C Programming Notes
JavaScripttttttttttttttttttttttttttttttttttttttt.ppt
C++ problem solving operators ( conditional operators,logical operators, swit...
Java script session 4
Data Structures- Part1 overview and review
Java-Programming.forBSITSTUDENTfreespptx
Ad

More from Codewizacademy (20)

PPTX
Implementing OODA Loop in online teaching
PPTX
Tie up loose ends
PPTX
PPTX
PPTX
PPTX
Organizing content of course
PPTX
Rules and policies for course
PPTX
Content Creation
PPTX
Taxonomies
PPTX
Course outline
PPTX
Course development
PPTX
PPTX
Conditional Constructs in Javascript
PPTX
Displaying message on web page in Javascript
PPTX
Storage in programming
PPTX
Cyber Security
PPTX
Website Security
PPTX
Website Cookies
PPTX
GDPR- General Data Protection Regulation
PPTX
CSS- Cascading Style Sheet
Implementing OODA Loop in online teaching
Tie up loose ends
Organizing content of course
Rules and policies for course
Content Creation
Taxonomies
Course outline
Course development
Conditional Constructs in Javascript
Displaying message on web page in Javascript
Storage in programming
Cyber Security
Website Security
Website Cookies
GDPR- General Data Protection Regulation
CSS- Cascading Style Sheet
Ad

Recently uploaded (20)

PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
Introduction and Scope of Bichemistry.pptx
PPTX
Nursing Management of Patients with Disorders of Ear, Nose, and Throat (ENT) ...
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
NOI Hackathon - Summer Edition - GreenThumber.pptx
PPTX
Open Quiz Monsoon Mind Game Final Set.pptx
PPTX
Pharma ospi slides which help in ospi learning
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
Revamp in MTO Odoo 18 Inventory - Odoo Slides
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PPTX
Cell Structure & Organelles in detailed.
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
Cardiovascular Pharmacology for pharmacy students.pptx
PDF
Mga Unang Hakbang Tungo Sa Tao by Joe Vibar Nero.pdf
PDF
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Introduction and Scope of Bichemistry.pptx
Nursing Management of Patients with Disorders of Ear, Nose, and Throat (ENT) ...
Abdominal Access Techniques with Prof. Dr. R K Mishra
human mycosis Human fungal infections are called human mycosis..pptx
STATICS OF THE RIGID BODIES Hibbelers.pdf
NOI Hackathon - Summer Edition - GreenThumber.pptx
Open Quiz Monsoon Mind Game Final Set.pptx
Pharma ospi slides which help in ospi learning
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
O5-L3 Freight Transport Ops (International) V1.pdf
Revamp in MTO Odoo 18 Inventory - Odoo Slides
Renaissance Architecture: A Journey from Faith to Humanism
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
Cell Structure & Organelles in detailed.
Anesthesia in Laparoscopic Surgery in India
Cardiovascular Pharmacology for pharmacy students.pptx
Mga Unang Hakbang Tungo Sa Tao by Joe Vibar Nero.pdf
Mark Klimek Lecture Notes_240423 revision books _173037.pdf

Programming fundamentals through javascript

  • 1. Programming in Java Script Java Script Programming Fundamentals
  • 2. Java Script • Programming language of the web • Works in unison with HTML and CSS for web page • Code interpreted line by line by the javascript engine built within web browser
  • 3. Different from HTML & CSS • HTML – Structure of web page • CSS – Layout and Design • Java Script – Behaviour/Interaction
  • 4. Use of JS • Adds dynamic components • Helps interaction with user • Can be deferred loading – Increases site speed
  • 5. How to write JS code • 2 ways of writing JS – External file – Embedded within HTML
  • 6. Tags in HTML to embed JS <script language="javascript"> .....js code.... </script>
  • 7. JS embedded within HTML <!DOCTYPE html> <html> <head> <title>Today's Date</title> <script> let date1 = new Date(); alert("Today's date is " + date1); </script> </head> <body> </body> </html>
  • 8. Tags in HTML to link external JS <!DOCTYPE html> <html> <head> <title>Today's Date</title> <script src="myscript.js"> </script> </head> <body> <button type="button" onclick="firstFunction()">Check Today's Date</button> </body> </html>
  • 9. External JS Code in myscript.js function firstFunction() { let date1 = new Date(); alert("Today's date is " + date1); }
  • 11. Program • Series of instructions • Input • Process • Output • Instruction is given for every function
  • 12. Programming • Writing program in specific language • Logically putting the solution together • Breaking up solution into steps • Writing instructions for every step
  • 13. 3 Programming Fundamentals • Storage • Conditional Constructs • Iteration
  • 14. Storage • Save Data • Input Data – Data from user input • Processed Data – Data worked upon • Output Data – Message
  • 15. Types of storage • Variable • Constants • Arrays
  • 16. Variables • Named storage location in memory • Holds a single value • Value can change
  • 17. Constants • Named storage location in memory • Holds a single value • Value cannot change once assigned
  • 18. Arrays • Named storage location in memory • Holds single or multiple values • Value(s) can change • Single array can contain one or more elements • Each element has a value assigned to it • All the elements of an array need to store values of same data type • Eg: int array of 5 elements will store 5 individual values of integer type only. Cannot contain one integer, one float, one string or any mix of it.
  • 19. Conditional Constructs • Applying Logic – Yes-> Do this – No-> Do that • Black or White • Zero or One • Binary • There is "No Grey Zone" – If it is not yes or no then its an Error
  • 20. If-Elseif-Else Ladder • Check different options through permutations and combinations • Conditions depend on number of possible options • For checking different conditions use appropriate operators
  • 21. If 1. IF MARKS>40 PRINT:"Pass" 2. IF CHOICE=="Hunger Games" PRINT:"Fiction"
  • 22. If-else 1. IF MARKS>40 PRINT: "Pass" ELSE PRINT: "Fail" 2. IF CHOICE=="Hunger Games" PRINT: "Fiction" ELSE PRINT: "Comedy"
  • 23. If-elseif-else 1. IF MARKS>40 PRINT: "Pass" ELSE IF MARKS==40 PRINT:"Just Pass" ELSE PRINT:"Fail" 2. IF CHOICE=="Hunger Games" PRINT: "Fiction" ELSE IF CHOICE=="Pride & Prejudice" PRINT: "Classic" ELSE PRINT: "Comedy"
  • 24. Operators • Different conditions -> different operations – Logical operators – Arithmetic operators – Relational operators
  • 25. Relational • To make a comparison while checking a condition, use relational operators. Operator Functionality Let’s consider x=5; y=10; > More Than x>y; False < Less Than x<y; True >= More Than or Equal To x>=y; False <= Less Than or Equal To x<=y; True == Equal to x==y; False != Not Equal to x!=y; True
  • 26. Logical • To combine two or more situations of conditional checking use, logical operators. Operator Functionality Condition Example && Both the sides of operator should result true x<y && y!=x True x<y && y==x False || Either side of operator should result true x<y || y!=x True x<y || y!=x True ! Inverse the result x!<y False
  • 27. Arithmetic • To compute arithmetic value we use Arithmetic Operators. Operator Functionality Condition Example + Addition x+y 15 - Subtraction x-y -5 * Multiplication x*y 50 / Division x/y 0 % Remainder x%y 5
  • 28. Iteration • Repetition of instructions • Based on Logic • Continue till condition is fulfilled • Condition is not fulfilled-> stop processing & break loop • Move to line of code outside the loop boundary
  • 29. Types of loops • For – Invariant check • While – Pre-condition check • Do-while – Post-condition check
  • 30. For • Steps – Initialize – Condition – Process – Increment/Decrement BEGIN INITIALISE vitaminc=0 FOR (int vitaminc=0; vitaminc<10; vitaminc++) PRINT: "Vitamin C Added" END FOR PRINT: "Total amount of vitamin"+vitaminc END
  • 31. While • Steps – Initialize – Condition – Process – Increment/decrement BEGIN INITIALISE choice="Orange" INITIALIZE vitaminc=0 WHILE (choice=="Orange") PRINT: "Vitamin C Added" vitaminc++ GET: choice END WHILE PRINT: "Total amount of vitamin"+vitaminc END
  • 32. Do-While • Steps – Initialize – Process – Increment/Decrement – Condition BEGIN INITIALISE choice=" " INITIALISE vitaminc=0 DO PRINT: "Vitamin C Added" vitaminc++ GET: choice WHILE(choice=="Orange") PRINT: "Total amount of vitamin"+vitaminc END