Content ITV PRO
This is Itvedant Content department
Learning Outcome
6
Control default browser behavior using preventDefault()
5
Identify and use common mouse,keyboard,form and window events
4
Explain why addEventListener is preferred over onclick
3
Use addEventListener() and removeEventListener() correctly
2
Connect user actions to Javascript using event listeners
1
Explain what browser events are and why they exist
Choose cool, soft colors instead of vibrant colors
Max 6 Points for Summary & Min 4
Key Lessons And Insights Gained From Our Previous Session
For Loop
Before We Start Coding,Let's Understand The Key Concepts We'll Cover Today
While Loop
Type Conversion Functions
While Loop
Type Conversion Functions
They use currency detector machines with UV lights and other methods to check if money is real
Let's code a basic currency detector using a while loop
By using a while loop that executes code as long as the condition is true
START
CONDITION
STATEMENT
END
False
True
By using a while loop that executes code as long as the condition is true
If the condition is true, the loop's code block will execute repeatedly
START
CONDITION
STATEMENT
True
By using a while loop that executes code as long as the condition is true
If the condition is true, the loop's code block will execute repeatedly
START
CONDITION
STATEMENT
True
By using a while loop that executes code as long as the condition is true
If the condition in a while loop is false, the loop terminates and the code block does not execute
START
CONDITION
END
False
parseInt()
Converts a string to a integer
parseFloat()
Converts to a decimal number
String()
Converts to a string
Boolean()
Converts to a boolean
Number()
Converts to a number
01
02
03
04
05
let currency;
let value;
let total = 0;
while(true){
currency=(prompt("Currency is present enter y:"));
if (currency == "y"){
value=parseInt(prompt("Enter the Note amount:"));
if (value == 10 || value == 20 || value == 50 || value == 100 || value == 500){
console.log(value + " Real currency");
total+=value;
}
else{
console.log( "Fake currency");
}
}
else{
break;
}
}
console.log(total);Here, we initialize the variables `currency` and `value`, and assign a value of zero to the `total`
let currency;
let value;
let total = 0;
while(true){
currency=(prompt("Currency is present enter y:"));
if (currency == "y"){
value=parseInt(prompt("Enter the Note amount:"));
if (value == 10 || value == 20 || value == 50 || value == 100 || value == 500){
console.log(value + " Real currency");
total+=value;
}
else{
console.log( "Fake currency");
}
}
else{
break;
}
}
console.log(total);Here the condition is true, it will enter the loop
So, now the loop has started executing, prompting the user to enter 'y' if currency is present and 'n' if not
OUTPUT:
let currency;
let value;
let total = 0;
while(true){
currency=(prompt("Currency is present enter y:"));
if (currency == "y"){
value=parseInt(prompt("Enter the Note amount:"));
if (value == 10 || value == 20 || value == 50 || value == 100 || value == 500){
console.log(value + " Real currency");
total+=value;
}
else{
console.log( "Fake currency");
}
}
else{
break;
}
}
console.log(total);If the user enters 'y', it jumps to the 'if' code block
OUTPUT:
let currency;
let value;
let total = 0;
while(true){
currency=(prompt("Currency is present enter y:"));
if (currency == "y"){
value=parseInt(prompt("Enter the Note amount:"));
if (value == 10 || value == 20 || value == 50 || value == 100 || value == 500){
console.log(value + " Real currency");
total+=value;
}
else{
console.log( "Fake currency");
}
}
else{
break;
}
}
console.log(total);Here, we take input from the user, asking them to enter the note amount
To convert the input to an integer, we use `parseInt`
We store the user's input in the 'value' variable
let currency;
let value;
let total = 0;
while(true){
currency=(prompt("Currency is present enter y:"));
if (currency == "y"){
value=parseInt(prompt("Enter the Note amount:"));
if (value == 10 || value == 20 || value == 50 || value == 100 || value == 500){
console.log(value + " Real currency");
total+=value;
}
else{
console.log( "Fake currency");
}
}
else{
break;
}
}
console.log(total);If the user enters a note amount of 10, 20, 50, 100, or 500, then, then it will print '[value Real currency], and the amount will be added to the total
let currency;
let value;
let total = 0;
while(true){
currency=(prompt("Currency is present enter y:"));
if (currency == "y"){
value=parseInt(prompt("Enter the Note amount:"));
if (value == 10 || value == 20 || value == 50 || value == 100 || value == 500){
console.log(value + " Real currency");
total+=value;
}
else{
console.log( "Fake currency");
}
}
else{
break;
}
}
console.log(total);If the user enters a note amount of 10, 20, 50, 100, or 500, then, then it will print '[value Real currency], and the amount will be added to the total
OUTPUT:
let currency;
let value;
let total = 0;
while(true){
currency=(prompt("Currency is present enter y:"));
if (currency == "y"){
value=parseInt(prompt("Enter the Note amount:"));
if (value == 10 || value == 20 || value == 50 || value == 100 || value == 500){
console.log(value + " Real currency");
total+=value;
}
else{
console.log( "Fake currency");
}
}
else{
break;
}
}
console.log(total);If the user enters a note amount other than 10, 20, 50, 100, or 500, it jumps to the else block and prints 'fake currency'
OUTPUT:
Summary
5
Build strong branding
4
Use different marketing channels
3
Target the right audience
2
Create and communicate value
1
Understand customer needs
Choose cool, soft colors instead of vibrant colors
Max 5 Points for Summary & Min 2
Quiz
Which platform is mainly used for professional networking and B2B marketing ?
A. Facebook
B. Instagram
C. LinkedIn
D. Snapchat
Quiz-Answer
Which platform is mainly used for professional networking and B2B marketing ?
A. Facebook
B. Instagram
C. LinkedIn
D. Snapchat
By Content ITV