SlideShare a Scribd company logo
JAVASCRIPT – BASIC –
AUROSKILLS
Content
Tables Of Content:-
1.1What Is Javascript?
1.2 JavascriptVariables
1.3 Functions
1.4 JavascriptVariable Scope
1.5 If Else Loop
1.6 Switch Case
1.7While-Loop
1.8 Do-while loop
1.9 For Loop
1.10 Factorial of a number
1.10.1 Factorial Approach
1.10.2 Recursive Approach
2.0 Fibonacci Series
Assignment :-
Assignment No:-1 Display Hello world
Assignment No:-2 HelloWorld In Head
Assignment no :-3 StoringValues InVariables and
Print It
Assignment no:-04 Declare Global And Local
Variables
Assignment no:-05 If Statement
Assignment no:-06 If Else Statement
Assignment no:-07 If Else If
Assignment no:-08 Switch Case
Assignment no:-09 While loop
Assignment no:-10 Do - While
Assignment no:-11 For-Loop
Assignment no:-12 IterativeApproach In Factorial
Assignment no:-13 Factorial Recursive Approach
Assignment no:-14 Recursion in Fibonanci Series
Assignment no:-15 Fibonanci Series
Task:-
1.0Task No:-1
2.0Task No:-2
3.0Task No:-3
4.0Task No:-4
5.0Task No:-5
6.0Task No:-6
7.0Task No:-7
1.1 What is JavaScript?
JavaScript is a dynamic computer programming language. It is lightweight and
most commonly used as a part of web pages, whose implementations allow client-
side script to interact with the user and make dynamic pages. It is an interpreted
programming language with object-oriented capabilities.
Build In 1995.
Designed for creating network-centric applications
Complementary to and integrated with Java
Complementary to and integrated with Java
Assignment No:-1
• Display “Hello World”.
<html>
<body>
<Script>
document.write(“Hello World”);
</script>
</body>
</html>
TASK NO:-01
• “Hello World” In console.log
• “Hello World” In document.getelementbyID()
Assignment No:-2
• Display “Hello World”.in Head
<html>
<head>
<script>
document.write(“Hello World”);
</script>
</head>
TASK NO:-02
• Use Console & ID to Print Hello World In Head part.
1.2 JavaScriptVariables:-
• Like many other programming languages, JavaScript has variables.Variables can be
thought of as named containers.You can place data into these containers and then refer
to the data simply by naming the container.
<script>
var money;
var name;
</script>
Assignment no :-3
• StoringValue inVariable And Print it
<script>
var name = “Boney”;
var money;
money = 2000;
Document.write(name);
Console.log(money) ;
</script>
1.3 Functions
• Functions are the main “building blocks” of the program.They allow the code to be called many times without repetition.
<script>
function showMessage()
{
alert( 'Hello everyone!’ );
}
showMessage();
</script>
1.4 JavaScriptVariable Scope
The scope of a variable is the region of your program in which it is defined.
JavaScript variables have only two scopes
• GlobalVariables: A global variable has global scope which means it can be
defined anywhere in your JavaScript code.
• LocalVariables: A local variable will be visible only within a function where
it is defined. Function parameters are always local to that function.
Assignment no:-04
• Declare Global And LocalVariable
<script>
var myVar=“global”;
function checkscope()
{
var myVar=“Local”;
document.write(myVar);
}
</script>
Task No :- 03
• Declare Add, Multiply & Divide in Function
• Then Declare one thing add , multiply or divide in global or local variable
1.5 If Else Loop:-
While writing a program, there may be a situation when you need to adopt one out of a
given set of paths. In such cases, you need to use conditional statements that allow your
program to make correct decisions and perform right actions.
JavaScript supports the following forms of if..else statement:
1) if statement
2) if...else statement
3) if...else if... Statement
if Statement :-The ‘if’ statement is the fundamental control statement that allows
JavaScript to make decisions and execute statements conditionally.
Assignment no:-05
• If Statement
<body>
<script>
var age = 20;
If (age > 18)
{
document.write(“<b>Qualify for driving</b>”);
}
</script>
</body>
Assignment no:-06
• If Else Statement:-
<script>
var age = 15 ;
If ( age > 18 )
{
document.write(“ qualify for driving”);
}
else
{
document.write(“Does not Qualify for Driving”);
}
</script>
Assignment no:-07
• if...else if... Statement
<script>
var book = “maths”;
If ( book == “history” )
{
document.write(“history book”);
}
else if (book == “maths” )
{
document.write(“book found”);
}
else
{
document.write(“Unkown book”);
}
</script>
Task No :- 04
• Perform different Output for
• If statement
• If else
• Else if
1.6 Switch-Case
• You can use multiple if...else…if statements, to perform a multiway branch.
However, this is not always the best solution, especially when all of the branches
depend on the value of a single variable.
• you can use a switch statement which handles exactly this situation, and it does so
more efficiently than repeated if...else if statements.
Switch-Case Syntax:-
switch (expression)
{
case condition 1: statement(s)
break;
case condition 2: statement(s)
break;
...
case condition n: statement(s)
break;
default: statement(s)
}
Assignment no:-08
• Switch-Case
<script>
var grade='A';
document.write("Entering switch block<br />");
switch (grade)
{
case 'A': document.write("Good job<br />");
break;
case 'B': document.write("Pretty good<br />");
break;
case 'C': document.write("Passed<br />");
break;
default: document.write("Unknown grade<br />")
}document.write("Exiting switch block");
</script>
1.7 While-Loop:-
• While writing a program, you may encounter a situation where you need to
perform an action over and over again. In such situations, you would need to write
loop statements to reduce the number of lines.
• The purpose of a while loop is to execute a statement or code block repeatedly as
long as an expression is true.
While-Loop syntax:-
while (expression)
{
Statement(s) to be executed if expression is true
}
Assignment no:-09
• While-Loop:-
<script >
var count = 0;
document.write("Starting Loop ");
while (count < 10)
{
document.write("CurrentCount : " + count + "<br />");
count++;
}
document.write("Loop stopped!");
</script>
1.8 Do-While-Loop:-
• The do...while loop is similar to the while loop except that the condition check
happens at the end of the loop.This means that the loop will always be executed
at least once, even if the condition is false.
Do-While-loop Syntax:-
Do
{
Statement(s) to be executed;
} while (expression);
Assignment no:-10
• Do-While
<script >
var count = 0;
document.write("Starting Loop" + "<br />");
Do
{
document.write("Current Count : " + count + "<br />");
count++;
}
while (count < 5);
document.write ("Loop stopped!");
</script>
Task No :- 05
• Perform task for
• Switch-case
• While loop
• Do while
1.9 For Loop:-
The ‘for’ loop is the most compact form of looping. It includes the following three
important parts:
1.The loop initialization where we initialize our counter to a starting value.The
initialization statement is executed before the loop begins.
2.The test statement which will test if a given condition is true or not. If the
condition is true, then the code given inside the loop will be executed, otherwise the
control will come out of the loop.
3.The iteration statement where you can increase or decrease your counter.
For-Loop Syntax:-
for (initialization; test condition; iteration statement)
{
Statement(s) to be executed if test condition is true
}
Assignment no:-11
• For-loop:-
<script type="text/javascript">
var count;
document.write("Starting Loop" + "<br />");
for(count = 0; count < 10; count++){
document.write("Current Count : " + count );
document.write("<br />");
}
document.write("Loop stopped!");
</script>
Task no:-06
• Perform task for for-loop.
• Use for and while loop in a single format.
• Use for and if loop in a single format.
1.10 Factorial Of a Number:-
Factorial of number is the product of all positive descending integers. Factorial of n
is denoted by n!. For example -
4! = 4 * 3 * 2 * 1 = 24
5! = 5 * 4 * 3 * 2 * 1 = 120
Formulas:-
factorial(n)=n∗(n−1)∗...∗1
factorial(n)=n∗factorial(n−1)
1.10.1 Factorial Approach:-
There are two ways to compute the factorial of a number in JavaScript.
• Iterative
• Recursive
1.The iterative approach
Keeping in mind the first definition of a factorial, the variable i is initially set equal to n and
is gradually decremented to 1. In each step, the result of the multiplication is stored in the
variable answer.
Assignment no:-12
• Iterative-Approach in Factorial :-
function factorial(n){
let answer = 1;
if (n == 0 || n == 1){
return answer;
}else{
for(var i = n; i >= 1; i--){
answer = answer * i;
} return answer;
}
}
let n = 4;
answer = factorial(n)
console.log("The factorial of " + n + " is " + answer);
</script>
1.10.2The recursive approach:-
• As stated above, the factorial of n can be found by finding the factorial of a
number one less than n, and then multiplying this answer with n. So the factorial
of n-1 can be thought of as a subproblem that needs to be computed first.
function call return value
factorial(1) 1 (base case)
factorial(2) 2 * 1 = 2
factorial(3) 3 * 2 = 6
factorial(4) 4 * 6 = 24
Assignment no:-13
• Factorial recursive approach:-
function factorial(n)
if(n == 0 || n == 1){
return 1;
//recursive case
}else{
return n * factorial(n-1);
}
}
let n = 4;
answer = factorial(n)
console.log("The factorial of " + n + " is " + answer);
2.0 Fibonacci Series:-
The sequence of Fibonacci numbers has the formula Fn = Fn-1 + Fn-2. In other
words, the next number is a sum of the two preceding ones.
First two numbers are 1, then 2(1+1), then 3(1+2),
5(2+3) and so on: 1, 1, 2, 3, 5, 8, 13, 21……….n
Assignment no:-14
• Recursion in Fibonacci series:-
function fibonacci(n) {
if (n === 1 || n === 0) {
return 1;
} else {
return fibonacci(n - 1) + fibonacci(n - 2);
}
}
console.log(fibonacci(10));
Assignment no:-15
• Fibonacci series:-
<script>
function fibonancci(n)
{
const arr = [1]
let current = 1;
let previous = 0;
if(n <= 1)
{
return arr
}
while(n>0)
{
current += previous
previous = current - previous
arr.push(current)
n-=1
}
return arr
}
console.log(fibonancci(10));
</script>
Task No:-07
• Print Factorial and Fibonacci series.
• Print Odd and even number
• Print Interment and decrement of a number
• Print A star pyramid.
• Print color in switch case condition.

More Related Content

What's hot

Java 8: the good parts!
Java 8: the good parts!Java 8: the good parts!
Java 8: the good parts!
Andrzej Grzesik
 
Advance Java Programs skeleton
Advance Java Programs skeletonAdvance Java Programs skeleton
Advance Java Programs skeleton
Iram Ramrajkar
 
Java 8 Workshop
Java 8 WorkshopJava 8 Workshop
Java 8 Workshop
Mario Fusco
 
Pragmatic functional refactoring with java 8
Pragmatic functional refactoring with java 8Pragmatic functional refactoring with java 8
Pragmatic functional refactoring with java 8
RichardWarburton
 
Java Lab Manual
Java Lab ManualJava Lab Manual
Java Lab Manual
Naveen Sagayaselvaraj
 
Say Hello To Ecmascript 5
Say Hello To Ecmascript 5Say Hello To Ecmascript 5
Say Hello To Ecmascript 5Juriy Zaytsev
 
Swiss army knife Spring
Swiss army knife SpringSwiss army knife Spring
Swiss army knife SpringMario Fusco
 
Introduction to nsubstitute
Introduction to nsubstituteIntroduction to nsubstitute
Introduction to nsubstitute
Suresh Loganatha
 
Finagle and Java Service Framework at Pinterest
Finagle and Java Service Framework at PinterestFinagle and Java Service Framework at Pinterest
Finagle and Java Service Framework at Pinterest
Pavan Chitumalla
 
JavaScript Functions
JavaScript Functions JavaScript Functions
JavaScript Functions
Reem Alattas
 
Alexey Tsoy Meta Programming in C++ 16.11.17
Alexey Tsoy Meta Programming in C++ 16.11.17Alexey Tsoy Meta Programming in C++ 16.11.17
Alexey Tsoy Meta Programming in C++ 16.11.17
LogeekNightUkraine
 
How and why I turned my old Java projects into a first-class serverless compo...
How and why I turned my old Java projects into a first-class serverless compo...How and why I turned my old Java projects into a first-class serverless compo...
How and why I turned my old Java projects into a first-class serverless compo...
Mario Fusco
 
Pragmatic sbt
Pragmatic sbtPragmatic sbt
Pragmatic sbt
Hermann Hueck
 
Workshop 5: JavaScript testing
Workshop 5: JavaScript testingWorkshop 5: JavaScript testing
Workshop 5: JavaScript testing
Visual Engineering
 
Node Boot Camp
Node Boot CampNode Boot Camp
Node Boot Camp
Troy Miles
 
Java programming lab_manual_by_rohit_jaiswar
Java programming lab_manual_by_rohit_jaiswarJava programming lab_manual_by_rohit_jaiswar
Java programming lab_manual_by_rohit_jaiswar
ROHIT JAISWAR
 
Rxjs vienna
Rxjs viennaRxjs vienna
Rxjs vienna
Christoffer Noring
 
Introduction to reactive programming & ReactiveCocoa
Introduction to reactive programming & ReactiveCocoaIntroduction to reactive programming & ReactiveCocoa
Introduction to reactive programming & ReactiveCocoa
Florent Pillet
 
Pragmatic functional refactoring with java 8 (1)
Pragmatic functional refactoring with java 8 (1)Pragmatic functional refactoring with java 8 (1)
Pragmatic functional refactoring with java 8 (1)
RichardWarburton
 

What's hot (20)

Java 8: the good parts!
Java 8: the good parts!Java 8: the good parts!
Java 8: the good parts!
 
Advance Java Programs skeleton
Advance Java Programs skeletonAdvance Java Programs skeleton
Advance Java Programs skeleton
 
Java 8 Workshop
Java 8 WorkshopJava 8 Workshop
Java 8 Workshop
 
Pragmatic functional refactoring with java 8
Pragmatic functional refactoring with java 8Pragmatic functional refactoring with java 8
Pragmatic functional refactoring with java 8
 
Java Lab Manual
Java Lab ManualJava Lab Manual
Java Lab Manual
 
Say Hello To Ecmascript 5
Say Hello To Ecmascript 5Say Hello To Ecmascript 5
Say Hello To Ecmascript 5
 
Swiss army knife Spring
Swiss army knife SpringSwiss army knife Spring
Swiss army knife Spring
 
Introduction to nsubstitute
Introduction to nsubstituteIntroduction to nsubstitute
Introduction to nsubstitute
 
Finagle and Java Service Framework at Pinterest
Finagle and Java Service Framework at PinterestFinagle and Java Service Framework at Pinterest
Finagle and Java Service Framework at Pinterest
 
JavaScript Functions
JavaScript Functions JavaScript Functions
JavaScript Functions
 
Alexey Tsoy Meta Programming in C++ 16.11.17
Alexey Tsoy Meta Programming in C++ 16.11.17Alexey Tsoy Meta Programming in C++ 16.11.17
Alexey Tsoy Meta Programming in C++ 16.11.17
 
How and why I turned my old Java projects into a first-class serverless compo...
How and why I turned my old Java projects into a first-class serverless compo...How and why I turned my old Java projects into a first-class serverless compo...
How and why I turned my old Java projects into a first-class serverless compo...
 
Rxjs ppt
Rxjs pptRxjs ppt
Rxjs ppt
 
Pragmatic sbt
Pragmatic sbtPragmatic sbt
Pragmatic sbt
 
Workshop 5: JavaScript testing
Workshop 5: JavaScript testingWorkshop 5: JavaScript testing
Workshop 5: JavaScript testing
 
Node Boot Camp
Node Boot CampNode Boot Camp
Node Boot Camp
 
Java programming lab_manual_by_rohit_jaiswar
Java programming lab_manual_by_rohit_jaiswarJava programming lab_manual_by_rohit_jaiswar
Java programming lab_manual_by_rohit_jaiswar
 
Rxjs vienna
Rxjs viennaRxjs vienna
Rxjs vienna
 
Introduction to reactive programming & ReactiveCocoa
Introduction to reactive programming & ReactiveCocoaIntroduction to reactive programming & ReactiveCocoa
Introduction to reactive programming & ReactiveCocoa
 
Pragmatic functional refactoring with java 8 (1)
Pragmatic functional refactoring with java 8 (1)Pragmatic functional refactoring with java 8 (1)
Pragmatic functional refactoring with java 8 (1)
 

Similar to Java script – basic auroskills (2)

Recursion and looping
Recursion and loopingRecursion and looping
Recursion and looping
xcoolanurag
 
06-Control-Statementskkkkkkkkkkkkkk.pptx
06-Control-Statementskkkkkkkkkkkkkk.pptx06-Control-Statementskkkkkkkkkkkkkk.pptx
06-Control-Statementskkkkkkkkkkkkkk.pptx
kamalsmail1
 
Lecture1.pdf
Lecture1.pdfLecture1.pdf
Lecture1.pdf
SakhilejasonMsibi
 
java in Aartificial intelligent by virat andodariya
java in Aartificial intelligent by virat andodariyajava in Aartificial intelligent by virat andodariya
java in Aartificial intelligent by virat andodariya
viratandodariya
 
JAVA in Artificial intelligent
JAVA in Artificial intelligentJAVA in Artificial intelligent
JAVA in Artificial intelligent
Virat Andodariya
 
System Verilog 2009 & 2012 enhancements
System Verilog 2009 & 2012 enhancementsSystem Verilog 2009 & 2012 enhancements
System Verilog 2009 & 2012 enhancementsSubash John
 
banaz hilmy.pptx
banaz hilmy.pptxbanaz hilmy.pptx
banaz hilmy.pptx
BaNaz8
 
Loop and while Loop
Loop and while LoopLoop and while Loop
Loop and while Loop
JayBhavsar68
 
Control Statement.ppt
Control Statement.pptControl Statement.ppt
Control Statement.ppt
sanjay
 
C++ control structure
C++ control structureC++ control structure
C++ control structurebluejayjunior
 
OS Process Synchronization, semaphore and Monitors
OS Process Synchronization, semaphore and MonitorsOS Process Synchronization, semaphore and Monitors
OS Process Synchronization, semaphore and Monitors
sgpraju
 
Pl sql programme
Pl sql programmePl sql programme
Pl sql programme
Dhilip Prakash
 
Pl sql programme
Pl sql programmePl sql programme
Pl sql programme
Dhilip Prakash
 
Programming in Arduino (Part 2)
Programming in Arduino  (Part 2)Programming in Arduino  (Part 2)
Programming in Arduino (Part 2)
Niket Chandrawanshi
 
Introduction to java 101
Introduction to java 101Introduction to java 101
Introduction to java 101
kankemwa Ishaku
 
Janakiram web
Janakiram webJanakiram web
Janakiram web
MARELLA CHINABABU
 
ServiceNow Knowledge11 Advanced Scripting & Debugging Lab
ServiceNow Knowledge11 Advanced Scripting & Debugging LabServiceNow Knowledge11 Advanced Scripting & Debugging Lab
ServiceNow Knowledge11 Advanced Scripting & Debugging Lab
John Roberts
 
Java 101
Java 101Java 101
Java 101
Manuela Grindei
 

Similar to Java script – basic auroskills (2) (20)

Recursion and looping
Recursion and loopingRecursion and looping
Recursion and looping
 
06-Control-Statementskkkkkkkkkkkkkk.pptx
06-Control-Statementskkkkkkkkkkkkkk.pptx06-Control-Statementskkkkkkkkkkkkkk.pptx
06-Control-Statementskkkkkkkkkkkkkk.pptx
 
Os3
Os3Os3
Os3
 
Lecture1.pdf
Lecture1.pdfLecture1.pdf
Lecture1.pdf
 
85ec7 session2 c++
85ec7 session2 c++85ec7 session2 c++
85ec7 session2 c++
 
java in Aartificial intelligent by virat andodariya
java in Aartificial intelligent by virat andodariyajava in Aartificial intelligent by virat andodariya
java in Aartificial intelligent by virat andodariya
 
JAVA in Artificial intelligent
JAVA in Artificial intelligentJAVA in Artificial intelligent
JAVA in Artificial intelligent
 
System Verilog 2009 & 2012 enhancements
System Verilog 2009 & 2012 enhancementsSystem Verilog 2009 & 2012 enhancements
System Verilog 2009 & 2012 enhancements
 
banaz hilmy.pptx
banaz hilmy.pptxbanaz hilmy.pptx
banaz hilmy.pptx
 
Loop and while Loop
Loop and while LoopLoop and while Loop
Loop and while Loop
 
Control Statement.ppt
Control Statement.pptControl Statement.ppt
Control Statement.ppt
 
C++ control structure
C++ control structureC++ control structure
C++ control structure
 
OS Process Synchronization, semaphore and Monitors
OS Process Synchronization, semaphore and MonitorsOS Process Synchronization, semaphore and Monitors
OS Process Synchronization, semaphore and Monitors
 
Pl sql programme
Pl sql programmePl sql programme
Pl sql programme
 
Pl sql programme
Pl sql programmePl sql programme
Pl sql programme
 
Programming in Arduino (Part 2)
Programming in Arduino  (Part 2)Programming in Arduino  (Part 2)
Programming in Arduino (Part 2)
 
Introduction to java 101
Introduction to java 101Introduction to java 101
Introduction to java 101
 
Janakiram web
Janakiram webJanakiram web
Janakiram web
 
ServiceNow Knowledge11 Advanced Scripting & Debugging Lab
ServiceNow Knowledge11 Advanced Scripting & Debugging LabServiceNow Knowledge11 Advanced Scripting & Debugging Lab
ServiceNow Knowledge11 Advanced Scripting & Debugging Lab
 
Java 101
Java 101Java 101
Java 101
 

Recently uploaded

Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
ArianaBusciglio
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
taiba qazi
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
RitikBhardwaj56
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
kitab khulasah nurul yaqin jilid 1 - 2.pptx
kitab khulasah nurul yaqin jilid 1 - 2.pptxkitab khulasah nurul yaqin jilid 1 - 2.pptx
kitab khulasah nurul yaqin jilid 1 - 2.pptx
datarid22
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
Krisztián Száraz
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
Bisnar Chase Personal Injury Attorneys
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
What is the purpose of studying mathematics.pptx
What is the purpose of studying mathematics.pptxWhat is the purpose of studying mathematics.pptx
What is the purpose of studying mathematics.pptx
christianmathematics
 

Recently uploaded (20)

Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
kitab khulasah nurul yaqin jilid 1 - 2.pptx
kitab khulasah nurul yaqin jilid 1 - 2.pptxkitab khulasah nurul yaqin jilid 1 - 2.pptx
kitab khulasah nurul yaqin jilid 1 - 2.pptx
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
What is the purpose of studying mathematics.pptx
What is the purpose of studying mathematics.pptxWhat is the purpose of studying mathematics.pptx
What is the purpose of studying mathematics.pptx
 

Java script – basic auroskills (2)

  • 1. JAVASCRIPT – BASIC – AUROSKILLS
  • 2. Content Tables Of Content:- 1.1What Is Javascript? 1.2 JavascriptVariables 1.3 Functions 1.4 JavascriptVariable Scope 1.5 If Else Loop 1.6 Switch Case 1.7While-Loop 1.8 Do-while loop 1.9 For Loop 1.10 Factorial of a number 1.10.1 Factorial Approach 1.10.2 Recursive Approach 2.0 Fibonacci Series Assignment :- Assignment No:-1 Display Hello world Assignment No:-2 HelloWorld In Head Assignment no :-3 StoringValues InVariables and Print It Assignment no:-04 Declare Global And Local Variables Assignment no:-05 If Statement Assignment no:-06 If Else Statement Assignment no:-07 If Else If Assignment no:-08 Switch Case Assignment no:-09 While loop Assignment no:-10 Do - While Assignment no:-11 For-Loop Assignment no:-12 IterativeApproach In Factorial Assignment no:-13 Factorial Recursive Approach Assignment no:-14 Recursion in Fibonanci Series Assignment no:-15 Fibonanci Series Task:- 1.0Task No:-1 2.0Task No:-2 3.0Task No:-3 4.0Task No:-4 5.0Task No:-5 6.0Task No:-6 7.0Task No:-7
  • 3. 1.1 What is JavaScript? JavaScript is a dynamic computer programming language. It is lightweight and most commonly used as a part of web pages, whose implementations allow client- side script to interact with the user and make dynamic pages. It is an interpreted programming language with object-oriented capabilities. Build In 1995. Designed for creating network-centric applications Complementary to and integrated with Java Complementary to and integrated with Java
  • 4. Assignment No:-1 • Display “Hello World”. <html> <body> <Script> document.write(“Hello World”); </script> </body> </html>
  • 5. TASK NO:-01 • “Hello World” In console.log • “Hello World” In document.getelementbyID()
  • 6. Assignment No:-2 • Display “Hello World”.in Head <html> <head> <script> document.write(“Hello World”); </script> </head>
  • 7. TASK NO:-02 • Use Console & ID to Print Hello World In Head part.
  • 8. 1.2 JavaScriptVariables:- • Like many other programming languages, JavaScript has variables.Variables can be thought of as named containers.You can place data into these containers and then refer to the data simply by naming the container. <script> var money; var name; </script>
  • 9. Assignment no :-3 • StoringValue inVariable And Print it <script> var name = “Boney”; var money; money = 2000; Document.write(name); Console.log(money) ; </script>
  • 10. 1.3 Functions • Functions are the main “building blocks” of the program.They allow the code to be called many times without repetition. <script> function showMessage() { alert( 'Hello everyone!’ ); } showMessage(); </script>
  • 11. 1.4 JavaScriptVariable Scope The scope of a variable is the region of your program in which it is defined. JavaScript variables have only two scopes • GlobalVariables: A global variable has global scope which means it can be defined anywhere in your JavaScript code. • LocalVariables: A local variable will be visible only within a function where it is defined. Function parameters are always local to that function.
  • 12. Assignment no:-04 • Declare Global And LocalVariable <script> var myVar=“global”; function checkscope() { var myVar=“Local”; document.write(myVar); } </script>
  • 13. Task No :- 03 • Declare Add, Multiply & Divide in Function • Then Declare one thing add , multiply or divide in global or local variable
  • 14. 1.5 If Else Loop:- While writing a program, there may be a situation when you need to adopt one out of a given set of paths. In such cases, you need to use conditional statements that allow your program to make correct decisions and perform right actions. JavaScript supports the following forms of if..else statement: 1) if statement 2) if...else statement 3) if...else if... Statement if Statement :-The ‘if’ statement is the fundamental control statement that allows JavaScript to make decisions and execute statements conditionally.
  • 15. Assignment no:-05 • If Statement <body> <script> var age = 20; If (age > 18) { document.write(“<b>Qualify for driving</b>”); } </script> </body>
  • 16. Assignment no:-06 • If Else Statement:- <script> var age = 15 ; If ( age > 18 ) { document.write(“ qualify for driving”); } else { document.write(“Does not Qualify for Driving”); } </script>
  • 17. Assignment no:-07 • if...else if... Statement <script> var book = “maths”; If ( book == “history” ) { document.write(“history book”); } else if (book == “maths” ) { document.write(“book found”); } else { document.write(“Unkown book”); } </script>
  • 18. Task No :- 04 • Perform different Output for • If statement • If else • Else if
  • 19. 1.6 Switch-Case • You can use multiple if...else…if statements, to perform a multiway branch. However, this is not always the best solution, especially when all of the branches depend on the value of a single variable. • you can use a switch statement which handles exactly this situation, and it does so more efficiently than repeated if...else if statements.
  • 20. Switch-Case Syntax:- switch (expression) { case condition 1: statement(s) break; case condition 2: statement(s) break; ... case condition n: statement(s) break; default: statement(s) }
  • 21. Assignment no:-08 • Switch-Case <script> var grade='A'; document.write("Entering switch block<br />"); switch (grade) { case 'A': document.write("Good job<br />"); break; case 'B': document.write("Pretty good<br />"); break; case 'C': document.write("Passed<br />"); break; default: document.write("Unknown grade<br />") }document.write("Exiting switch block"); </script>
  • 22. 1.7 While-Loop:- • While writing a program, you may encounter a situation where you need to perform an action over and over again. In such situations, you would need to write loop statements to reduce the number of lines. • The purpose of a while loop is to execute a statement or code block repeatedly as long as an expression is true.
  • 23. While-Loop syntax:- while (expression) { Statement(s) to be executed if expression is true }
  • 24. Assignment no:-09 • While-Loop:- <script > var count = 0; document.write("Starting Loop "); while (count < 10) { document.write("CurrentCount : " + count + "<br />"); count++; } document.write("Loop stopped!"); </script>
  • 25. 1.8 Do-While-Loop:- • The do...while loop is similar to the while loop except that the condition check happens at the end of the loop.This means that the loop will always be executed at least once, even if the condition is false.
  • 26. Do-While-loop Syntax:- Do { Statement(s) to be executed; } while (expression);
  • 27. Assignment no:-10 • Do-While <script > var count = 0; document.write("Starting Loop" + "<br />"); Do { document.write("Current Count : " + count + "<br />"); count++; } while (count < 5); document.write ("Loop stopped!"); </script>
  • 28. Task No :- 05 • Perform task for • Switch-case • While loop • Do while
  • 29. 1.9 For Loop:- The ‘for’ loop is the most compact form of looping. It includes the following three important parts: 1.The loop initialization where we initialize our counter to a starting value.The initialization statement is executed before the loop begins. 2.The test statement which will test if a given condition is true or not. If the condition is true, then the code given inside the loop will be executed, otherwise the control will come out of the loop. 3.The iteration statement where you can increase or decrease your counter.
  • 30. For-Loop Syntax:- for (initialization; test condition; iteration statement) { Statement(s) to be executed if test condition is true }
  • 31. Assignment no:-11 • For-loop:- <script type="text/javascript"> var count; document.write("Starting Loop" + "<br />"); for(count = 0; count < 10; count++){ document.write("Current Count : " + count ); document.write("<br />"); } document.write("Loop stopped!"); </script>
  • 32. Task no:-06 • Perform task for for-loop. • Use for and while loop in a single format. • Use for and if loop in a single format.
  • 33. 1.10 Factorial Of a Number:- Factorial of number is the product of all positive descending integers. Factorial of n is denoted by n!. For example - 4! = 4 * 3 * 2 * 1 = 24 5! = 5 * 4 * 3 * 2 * 1 = 120 Formulas:- factorial(n)=n∗(n−1)∗...∗1 factorial(n)=n∗factorial(n−1)
  • 34. 1.10.1 Factorial Approach:- There are two ways to compute the factorial of a number in JavaScript. • Iterative • Recursive 1.The iterative approach Keeping in mind the first definition of a factorial, the variable i is initially set equal to n and is gradually decremented to 1. In each step, the result of the multiplication is stored in the variable answer.
  • 35. Assignment no:-12 • Iterative-Approach in Factorial :- function factorial(n){ let answer = 1; if (n == 0 || n == 1){ return answer; }else{ for(var i = n; i >= 1; i--){ answer = answer * i; } return answer; } } let n = 4; answer = factorial(n) console.log("The factorial of " + n + " is " + answer); </script>
  • 36. 1.10.2The recursive approach:- • As stated above, the factorial of n can be found by finding the factorial of a number one less than n, and then multiplying this answer with n. So the factorial of n-1 can be thought of as a subproblem that needs to be computed first. function call return value factorial(1) 1 (base case) factorial(2) 2 * 1 = 2 factorial(3) 3 * 2 = 6 factorial(4) 4 * 6 = 24
  • 37. Assignment no:-13 • Factorial recursive approach:- function factorial(n) if(n == 0 || n == 1){ return 1; //recursive case }else{ return n * factorial(n-1); } } let n = 4; answer = factorial(n) console.log("The factorial of " + n + " is " + answer);
  • 38. 2.0 Fibonacci Series:- The sequence of Fibonacci numbers has the formula Fn = Fn-1 + Fn-2. In other words, the next number is a sum of the two preceding ones. First two numbers are 1, then 2(1+1), then 3(1+2), 5(2+3) and so on: 1, 1, 2, 3, 5, 8, 13, 21……….n
  • 39. Assignment no:-14 • Recursion in Fibonacci series:- function fibonacci(n) { if (n === 1 || n === 0) { return 1; } else { return fibonacci(n - 1) + fibonacci(n - 2); } } console.log(fibonacci(10));
  • 40. Assignment no:-15 • Fibonacci series:- <script> function fibonancci(n) { const arr = [1] let current = 1; let previous = 0; if(n <= 1) { return arr } while(n>0) { current += previous previous = current - previous arr.push(current) n-=1 } return arr } console.log(fibonancci(10)); </script>
  • 41. Task No:-07 • Print Factorial and Fibonacci series. • Print Odd and even number • Print Interment and decrement of a number • Print A star pyramid. • Print color in switch case condition.