???? Day 25 of #100DaysOfTypeScript Challenge!
Mubashir Bashir
Web Developer | Wordpress Developer | Shopify | React JS | GenAI learning Journey
??Question_73: Assigning and Updating Variables: Create a function where you declare a variable using let and assign an initial value. Then, update its value within the same function and log both the initial and updated values
function updateVariable(){
let number = 10;
console.log("Initial Value: ",number)
number = 20;
console.log("Updated Value: ",number)
}
updateVariable()
??Question_74: Swapping Variables: Demonstrate how to swap the value of two variables. Start with variables a = 5 and b = 10, then swap their values so that a becomes 10 and b becomes 5.
let swapValues = ()=>{
let a =5,b=10
console.log('Initial Value of a = ',a)
console.log('Initial Value of b = ',b)
let temp = a;
a =b;
b = temp;
console.log('Value of a after swapp a = ',a)
console.log('Value of b after swapp b = ',b)
}
swapValues()
??Question_75: Compound Assignment Operators : Use compound assignment operators to simplify arithmetic operations. Start with x = 4 and perform a series of operations (addition, subtraction, multiplication, division) on x using compound operators.
function compoundOperators(){
let x = 4
console.log("initial value of x is ",4)
x +=10
console.log("After additon",x)
x -= 10
console.log("After Subtraction",x)
x *= 4
console.log("After Multiplication",x)
x /= 8
console.log("After Division",x)
}
compoundOperators()