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

Similar to Programming fundamentals through javascript (20)

PPTX
JavaScript Session 2
Muhammad Ehtisham Siddiqui
 
PPSX
DIWE - Programming with JavaScript
Rasan Samarasinghe
 
PPT
Chaptfffffuuer05.PPT
sdvdsvsdvsvds
 
PDF
Basic_C++ Notes with problema from Preethi arora and suneetha arora.pdf
Computer Programmer
 
PDF
Programming for Problem Solving
Kathirvel Ayyaswamy
 
PPT
Introduction to javascript.ppt
BArulmozhi
 
PPTX
Lewis_Cocking_AP_Decision_Making_For_Coding
GeorgeTsak
 
PDF
JavaScript for beginners
Shahrukh Ali Khan
 
PPTX
C++ IF STATMENT AND ITS TYPE
UNIVERSITY OF ENGINEERING AND TECHNOLOGY TAXILA
 
PPTX
C programming slide c03
pradeep dwivedi
 
PPTX
Module2.2_Operators-in-C-Programming.pptx
MaheshKini3
 
PDF
learn basic to advance C Programming Notes
bhagadeakshay97
 
PDF
Javascript breakdown-workbook
HP IT GROUP (TEBIM TEBITAGEM) TTGRT HP E-TİCARET
 
PPT
JavaScripttttttttttttttttttttttttttttttttttttttt.ppt
ankitasaha010207
 
PDF
C++ problem solving operators ( conditional operators,logical operators, swit...
mshakeel44514451
 
PPT
Ch3
aamirsahito
 
PPTX
Java script session 4
Saif Ullah Dar
 
PPT
L05if
Kgr Sushmitha
 
PPT
Data Structures- Part1 overview and review
Abdullah Al-hazmy
 
PPTX
Java-Programming.forBSITSTUDENTfreespptx
oliverrobertjames
 
JavaScript Session 2
Muhammad Ehtisham Siddiqui
 
DIWE - Programming with JavaScript
Rasan Samarasinghe
 
Chaptfffffuuer05.PPT
sdvdsvsdvsvds
 
Basic_C++ Notes with problema from Preethi arora and suneetha arora.pdf
Computer Programmer
 
Programming for Problem Solving
Kathirvel Ayyaswamy
 
Introduction to javascript.ppt
BArulmozhi
 
Lewis_Cocking_AP_Decision_Making_For_Coding
GeorgeTsak
 
JavaScript for beginners
Shahrukh Ali Khan
 
C programming slide c03
pradeep dwivedi
 
Module2.2_Operators-in-C-Programming.pptx
MaheshKini3
 
learn basic to advance C Programming Notes
bhagadeakshay97
 
JavaScripttttttttttttttttttttttttttttttttttttttt.ppt
ankitasaha010207
 
C++ problem solving operators ( conditional operators,logical operators, swit...
mshakeel44514451
 
Java script session 4
Saif Ullah Dar
 
Data Structures- Part1 overview and review
Abdullah Al-hazmy
 
Java-Programming.forBSITSTUDENTfreespptx
oliverrobertjames
 

More from Codewizacademy (20)

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

Recently uploaded (20)

PDF
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
PDF
Characteristics, Strengths and Weaknesses of Quantitative Research.pdf
Thelma Villaflores
 
PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PDF
Governor Josh Stein letter to NC delegation of U.S. House
Mebane Rash
 
PPTX
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
PPTX
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PDF
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
PPTX
How to Create Odoo JS Dialog_Popup in Odoo 18
Celine George
 
PDF
Geographical Diversity of India 100 Mcq.pdf/ 7th class new ncert /Social/Samy...
Sandeep Swamy
 
PPTX
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
PDF
Geographical diversity of India short notes by sandeep swamy
Sandeep Swamy
 
PDF
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
PPTX
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
PPTX
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
PDF
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
PDF
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
PPTX
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
PDF
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
Characteristics, Strengths and Weaknesses of Quantitative Research.pdf
Thelma Villaflores
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
Governor Josh Stein letter to NC delegation of U.S. House
Mebane Rash
 
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
How to Create Odoo JS Dialog_Popup in Odoo 18
Celine George
 
Geographical Diversity of India 100 Mcq.pdf/ 7th class new ncert /Social/Samy...
Sandeep Swamy
 
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
Geographical diversity of India short notes by sandeep swamy
Sandeep Swamy
 
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
Ad

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