myName and assign it value
TechTIME use a built-in function to show the output in
alert box.
let myName = "TechTIME";
alert(myName );
score, assign value
90 to it and use built-in function to display output
You have scored 90% in exams in console.
let score = 90
console.log( 'You have scored',score+ '% in exams' )
name and assign it value
Iftikhar, another variable surname and
assign it value Umrani and a variable of
age and assign value 55. Show following
output to console.
My friend Iftikhar Umrani is 55 years old
let name = 'Iftikhar'
let surname = 'Umrani'
let age = 55
console.log('My friend',name,surname,'is',age,'years old')
channel and store value
techTIME . Create another variable named
mylist = ['Chicken','Milk','Vegitable','Flour']
use a built-in function/property to show datatype of both variables in
console.
let channel = 'TechTIME';
let mylist = ['Chicken','Milk','Vegitable','Flour'];
console.log( typeof channel );
console.log( typeof mylist );
Output:
'string'
'array'
badal, mateen and shahnawaz. If user inputs age of Badal
as 19 and Mateen and Shahnawaz as 18. Show following output using
comparison operators.
let ageBadal = prompt('Enter the age of Badal')
let ageMateen = prompt('Enter the age of Mateen')
let ageShahnawaz =
prompt('Enter the age of Shahnawaz')
if (ageMateen < ageBadal ) {
console.log('Mateen is younger than Badal')
}
if (ageBadal > ageMateen) {
console.log('Badal is older than Mateen')
}
if (ageShahnawaz == ageMateen) {
console.log('Mateen and Shahnawaz are same age')
}
42 * 38 in JavaScript?
and show it in console.
Method 1
console.log( 42*38 )
Method 2
let x = 42, y=38
console.log( x*y )
Method 3
let x = 42, y=38
let ans = x*y
console.log( ans )
Muzammil
and age is 18 It should output "Muzammil has started programming"
else if age is greater than 18 then it should output
"Muzammil is a good programmer" otherwise it should output
"Muzammil is newbie"
let ageMuz = prompt('Enter the of Muzammil');
if ( ageMuz == 18 ) {
console.log('Muzammil has started programming')
} else if ( ageMuz > 18 ) {
console.log('Muzammil is a good programmer')
} else {
console.log('Muzammil is newbie')
}
8 hours/day regularly and his rate per hour is 200 PKR. For every extra
hour his rate per hour is 1.5 times more than regular hour.
What will be his monthly (30 days) salary if he works 1 hour extra every day.
workHours = prompt('Enter the number of hours employee worked/day');
numberDays = prompt('Enter the number of days this month');
let regualarHours = 8;
let regularRate = 200;
regularRatePerDay = regularHours * regularRate
extraHourRatePerDay = (1.5 * regularRate) * ( workHours - regualarHours )
salary = regularRatePerDay + extraHourRatePerDay;
console.log(salary);
Fahrenhiet of provided celcius C(value) is : F(value)
Celcius of provided Fahrenhiet F(value) is : C(value)
let cel = prompt('Enter the value in C');
let far = prompt('Enter the value in F')
newF = cel * ( 9/5 ) + 32;
newC = ( 5/9 ) * ( far - 32 )
console.log(`Fahrenhiet of provided celcius ${cel} is : F(${newF})`)
console.log(`Celcius of provided Fahrenhiet ${far} is : F(${newC})`)
let a = 15;
let b = 20;
formula = (a + b) ** 2
console.log(formula);