JavaScript question and answer with demo page - 1

JavaScript Quiz - Interview questions and answers - We thank founder of JavaScript Brendan Eich

Welcome to JavaScript Quiz - Objective and Subjective

We thank the great Mr. Brendan Eich, the founder of the JavaScript scripting language

You may read more about founder of JavaScript here...

1) What is the correct command for Alert pop up message in JavaScript?

1. alert(hello);
2. document.write("hello");
3. alert("hello");


2) How do you open website https://workspace.google.com in JavaScript?

1. window.open("https://workspace.google.com");
2. open("https://workspace.google.com");
3. a href="https://workspace.google.com";


3) How do you write Array containing five fruit names (Apple, Orange, Banana, Grapes and Papaya) through Alert pop up in JavaScript?

1. var fruitesfive = [Apple,Orange,Banana,Grapes,Papaya];
2. var fruitesfive = ["Apple","Orange","Banana","Grapes","Papaya"];
3. var fruitesfive = ("Apple","Orange","Banana","Grapes","Papaya");


4) Write a code to select and display only fruit, Banana from the above five fruits through Alert pop up in JavaScript?

1. var fruitesfive = ["Apple","Orange","Banana","Grapes","Papaya"];
alert(fruitesfive[2]);
2. var fruitesfive = ["Apple","Orange","Banana","Grapes","Papaya"];
alert[fruitesfive(2)];
3. var fruitesfive = {"Apple","Orange","Banana","Grapes","Papaya"};
alert[fruitesfive(2)];


5) Write a code to display the Current Date and Time through Alert pop up in JavaScript?

1. var today = new Date();
alert(today);
2. var today = date();
alert(today);
3. var today = DateTime();
alert(today);




Host gator will be a great hosting solution for your business. User friendly control panel. Friendly customer service. Hostgator will guard your website. For your domain registration, Web hosting etc., just click above picture. Good luck. 24 hours chatting support.

6) Write a code to convert word "google for small business" to UPPER CASE LETTERS and display through Alert Pop Up in JavaScript?

1. var mytext = "google for small business";
var mytextupper = mytext.toUpper();
alert(mytextupper);
2. var mytext = "google for small business";
var mytextupper = mytext.toUpperCase();
alert(mytextupper);
3. var mytext = "google for small business";
var mytextupper = toUpperCase(mytext);
alert(mytextupper);


7) What is DOM in JavaScript?

1. Document Object Model
2. Document Opening Manner
3. Document Operating Machine


Microsoft Student Developer Imagine Cup Competition. Please click to proceed...

Python programming language tutorial. Please click to proceed...
Infosys plans to hire 24000 fresh graduates from Campuses in FY - Financial Year - 2022. Just click to proceed...

8) Write a program in JavaScript which will add two numbers 1000 and 1040 and display through P element, Paragraph element, on click of a button using DOM feature? Choose correct code from the below three options

1.
< script >
function adddom()
{
var number1 = 1000;
var number2 = 1040;
var total = number1 + number2;
document.getelementbyId("an2").innerHTML = "total of two numbers: " + total;
}
< /script >
2.
< script >
function adddom()
{
var number1 = 1000;
var number2 = 1040;
var total = number1 + number2;
document.getElementById("an2").innerhtml = "total of two numbers: " + total;
}
< /script >
3.
< script >
function adddom()
{
var number1 = 1000;
var number2 = 1040;
var total = number1 + number2;
document.getElementById("an2").innerHTML = "total of two numbers: " + total;
}
< /script >


9) What is SetTimeout() in JavaScript?

1. Executes a function, once, after waiting a specified number of milliseconds.
2. Executes a function, over and over again, at specified time interval.
3. Executes a function immediately.


10) Write a program in JavaScript which will navigate to a Blog https://goodmorningimages1.blogspot.com after 10 seconds on clicking the button, using setTimeout method(). Also display text "Please wait. you're being navigated to Good Morning Wish pictures Blog " Choose correct code from the below three options

1.
< script >
function visitblog()
{
window.location = "https://goodmorningimages1.blogspot.com";
document.getElementById("an4").innerhtml = "Please wait. you're being navigated to Good Morning Wish pictures Blog ";
}
< /script >
< button onclick="setTimeout(visitblog, 10000);" >Click here to visit Good morning greeting pictures blog after 10 seconds

2.
< script >
function visitblog()
{
window.locate = "https://goodmorningimages1.blogspot.com";
document.getElementById("an4").innerHTML = "Please wait. you're being navigated to Good Morning Wish pictures Blog ";
}
< /script >
< button onclick="setTimeout(visitblog, 10000);" >Click here to visit Good morning greeting pictures blog after 10 seconds

3.
< script >
function visitblog()
{
window.location = "https://goodmorningimages1.blogspot.com";
document.getElementById("an4").innerHTML = "Please wait. you're being navigated to Good Morning Wish pictures Blog ";
}
< /script >
< button onclick="setTimeout(visitblog, 10000);" >Click here to visit Good morning greeting pictures blog after 10 seconds


11) Write a program in JavaScript, on click of a Button to prompt visitor of website to enter name and display back with message, Hello PLUS entered name using Alert pop up. Also display the same in p element. Choose correct script from the three options below.

1.
< script >
function promptinput
{
var yourname = prompt("Enter Name: ", "Your Name Here");
alert("Hello " + yourname);
document.getElementById("an5").innerHTML = "Hello " + yourname;
}
< /script >
< button onclick="promptinput()" > Click here to prompt for user input < / button >

2.
< script >
function promptinput()
{
var yourname = prompt("Enter Name: ", "Your Name Here");
alert("Hello " + yourname);
document.getElementById("an5").innerHTML = "Hello " + yourname;
}
< /script >
< button onclick="promptinput()" > Click here to prompt for user input < / button >

3.
< script >
function promptinput()
{
var yourname = prompt("Enter Name: ", "Your Name Here")
alert("Hello " + yourname);
document.getElementByID("an5").innerHTML = "Hello " + yourname;
}
< /script >
< button onclick="promptinput()" > Click here to prompt for user input < / button >


12) What are the Primitive Data types in JavaScript? Below are the options

1.
string, number, boolean, null, undefined

2.
string, Int, boolean, float, undefined

3.
string, char, boolean, null, undefined


13) Show the example for each of the Primitive Data types string, number, boolean, null, undefined in JavaScript and display the type on click of a button. Below are the options

1.
< script >
function datatypeexample()
{
var dtypes = ["string"," number"," boolean"," null"," undefined"];
alert("Primitive Data types are: " + dtypes);
var myname = "Raja";
alert("My Name is: " + myname);
alert(typeof(myname));
var mysalary = 105000;
alert ("My Salary is: " + mysalary);
alert(typeof(mysalary));
var mysalary = true;
alert(mysalary);
alert(typeof(mysalary));
var negativenumber = null;
alert(negativenumber);
alert(typeof(negativenumber));
document.getElementById("an7").innerHTML = "Primitive Data Types are " + dtypes + "." +" You have seen the examples through alert pop up box";
}
< /script >
2.
< script >
function datatypeexample()
{
var dtypes = ["string"," number" " boolean"," null"," undefined"];
alert(Primitive Data types are: + dtypes);
var myname = "Raja";
alert("My Name is: " + myname);
alert(typeof(myname));
var mysalary = 105000;
alert ("My Salary is: " + mysalary);
alert(typeof(mysalary));
var mysalary = true;
alert(mysalary);
alert(typeof(mysalary));
var negativenumber = null;
alert(negativenumber);
alert(typeof(negativenumber));
document.getElementById("an7").innerHTML = "Primitive Data Types are " + dtypes + "." +" You have seen the examples through alert pop up box";
}
< /script >
3.
< script >
function datatypeexample()
{
var dtypes = ["string"," number"," boolean"," null"," undefined"];
alert("Primitive Data types are: " + dtypes);
var myname = "Raja";
alert("My Name is: " + myname);
alert(type(myname));
var mysalary = 105000;
alert ("My Salary is: " + mysalary);
alert(typeof(mysalary));
var mysalary = true;
alert(mysalary);
alert(typeof(mysalary));
var negativenumber = null;
alert(negativenumber);
alert(typeof(negativenumber));
document.getElementById("an7").innerHTML = "Primitive Data Types are " + dtypes + "." +" You have seen the examples through alert pop up box";
}
< /script >

14) How will you link the external JavaScript file on the Website, Web page. Assuming the File name is webads.js. Choose correct option from the below list.

1.
< script ="webads.js">< /script>
2.
< script src="webads.js">< /script>
3.
< script source="webads">< /script>

15) Your customer is asking you to design a web page that reminds the website visitor with GREETING text "Hi" then line break and "This product is available with discount of 10%" every 3 seconds. How will you code the same by using setInterval() method of JavaScript. Choose correct option from below list.

1.
< script >
function alertreminder()
{
setInterval(function
{ alert("Hi\nThis product is available at a discount of 10%")}, 3000);
document.getElementById("an9").innerHTML = "Alert pop up reminder Count down has started, will display in 3 seconds";
}
< /script>

2.
< script >
function alertreminder()
{
setInterval(function()
{ alert("Hi\nThis product is available at a discount of 10%")}, 3000);
document.getElementById("an9").innerHTML = "Alert pop up reminder Count down has started, will display in 3 seconds";
}
< /script>

3.
< script >
function alertreminder()
{
setInterval(function()
{ alert("Hi\nThis product is available at a discount of 10%")} 3000);
document.getElementById("an9").innerHTML = "Alert pop up reminder Count down has started, will display in 3 seconds";
}
< /script>


16) Write a script to display only current date on the website on click of a button. Output display through alert pop up and also through p - paragraph element, name an10. Choose correct option from below list.

1.
< script >
function datedisplay()
{
var datetime = new Date;
var currentdate = datetime.toDateStr();
alert("Today's date: " +currentdate);
document.getElementById("an10").innerHTML = "Date of today is: " + currentdate;
}
< /script>

2.
< script >
function datedisplay()
{
var datetime = new toDate();
var currentdate = datetime.toDateString();
alert(Today's date: +currentdate);
document.getElementById("an10").innerHTML = "Date of today is: " + currentdate;
}
< /script>

3.
< script >
function datedisplay()
{
var datetime = new Date();
var currentdate = datetime.toDateString();
alert("Today's date: " +currentdate);
document.getElementById("an10").innerHTML = "Date of today is: " + currentdate;
}
< /script>


17) What is clearTimeout() method in JavaScript. Choose the correct option from the below list.

1.

ClearTimeout() method clears a time set with the setTimeout() method. The Id value returned by setTimeout() is used as parameter for the clearTimeout() method. For example, Navigation to another web page within a certain time limit can be stopped by your website visitor by clicking on clearTimeout() button click event.

2.

ClearTimeout() method doesn't clears a time set with the setTimeout() method.

3.

ClearTimeout() method clears a time set with the any other method in JavaScript.



18) You're developing a website for a vegetable restaurant which is offering, daily one type of Dosa dish (seven days seven different types of dosa and free fruit juice) with special discount and one free fruit juice. On click of a button, system day must be picked and display the special Dosa item and free juice name fixed for that day through alert pop up and p - paragraph element display. P - paragraph display with different text color, each day one color. P - paragraph element id is "an12". USE SWITCH CASE STATEMENT. Choose correct option from below list.

1.
< script >
function dayspecialitem()
{
var day;
switch (new Date().getDay())
{
case 0:
day = "Sunday - Special - Butter Masala Dosa with 10% less from normal price";
alert(Free with Butter Masala Dosa \n Mosambi Juice);
x = document.getElementById("an12");
x.style.color = "black";
break;
case 1:
day = "Monday - Special - Wheat or Atta Dosa with 12% less from normal price";
alert("Free with Wheat or Atta Dosa \n Orange Juice");
x = document.getElementById("an12");
x.style.color = "maroon";
break;
case 2:
day = "Tuesday - Special - Neer Dosa with 15% less from normal price";
alert("Free with Neer Dosa \n Grape Juice");
x = document.getElementById("an12");
x.style.color = "darkorange";
break;
case 3:
day = "Wednesday - Special - Ghee Dosa with 14% less from normal price";
alert("Free with Ghee Dosa \n Pine Apple Juice");
x = document.getElementById("an12");
x.style.color = "hotpink";
break;
case 4:
day = "Thursday - Special - Mysore Masala Dosa with 12% less from normal price";
alert("Free with Mysore Masala Dosa \n Apple Juice");
x = document.getElementById("an12");
x.style.color = "coral";
break;
case 5:
day = "Friday - Special - Set Dosa with 16% less from normal price";
alert("Free with Set Dosa\n Sapota Juice");
x = document.getElementById("an12");
x.style.color = "midnightblue";
break;
case 6:
day = "Saturday - Special - Cheese Dosa with 9% less from normal price";
alert("Free with Cheese Dosa\n Strawberry Juice");
x = document.getElementById("an12");
x.style.color = "darkorange";
break;
}
document.getElementById("an12").innerHTML = "Today is " + day;
}
< /script>

/*******/


2.
< script >
function dayspecialitem()
{
var day;
switch (new Date().getDay)
{
case 0:
day = "Sunday - Special - Butter Masala Dosa with 10% less from normal price";
alert("Free with Butter Masala Dosa \n Mosambi Juice");
x = document.getElementById("an12");
x.style.color = "black";
break;
case 1:
day = "Monday - Special - Wheat or Atta Dosa with 12% less from normal price";
alert("Free with Wheat or Atta Dosa \n Orange Juice");
x = document.getElementById("an12");
x.style.color = "maroon";
break;
case 2:
day = "Tuesday - Special - Neer Dosa with 15% less from normal price";
alert("Free with Neer Dosa \n Grape Juice");
x = document.getElementById("an12");
x.style.color = "darkorange";
break;
case 3:
day = "Wednesday - Special - Ghee Dosa with 14% less from normal price";
alert("Free with Ghee Dosa \n Pine Apple Juice");
x = document.getElementById("an12");
x.style.color = "hotpink";
break;
case 4:
day = "Thursday - Special - Mysore Masala Dosa with 12% less from normal price";
alert("Free with Mysore Masala Dosa \n Apple Juice");
x = document.getElementById("an12");
x.style.color = "coral";
break;
case 5:
day = "Friday - Special - Set Dosa with 16% less from normal price";
alert("Free with Set Dosa\n Sapota Juice");
x = document.getElementById("an12");
x.style.color = "midnightblue";
break;
case 6:
day = "Saturday - Special - Cheese Dosa with 9% less from normal price";
alert("Free with Cheese Dosa\n Strawberry Juice");
x = document.getElementById("an12");
x.style.color = "darkorange";
break;
}
document.getElementById("an12").innerHTML = "Today is " + day;
}
< /script >

/*******/


3.
< script >
function dayspecialitem()
{
var day;
switch (new Date().getDay())
{
case 0:
day = "Sunday - Special - Butter Masala Dosa with 10% less from normal price";
alert("Free with Butter Masala Dosa \n Mosambi Juice");
x = document.getElementById("an12");
x.style.color = "black";
break;
case 1:
day = "Monday - Special - Wheat or Atta Dosa with 12% less from normal price";
alert("Free with Wheat or Atta Dosa \n Orange Juice");
x = document.getElementById("an12");
x.style.color = "maroon";
break;
case 2:
day = "Tuesday - Special - Neer Dosa with 15% less from normal price";
alert("Free with Neer Dosa \n Grape Juice");
x = document.getElementById("an12");
x.style.color = "darkorange";
break;
case 3:
day = "Wednesday - Special - Ghee Dosa with 14% less from normal price";
alert("Free with Ghee Dosa \n Pine Apple Juice");
x = document.getElementById("an12");
x.style.color = "hotpink";
break;
case 4:
day = "Thursday - Special - Mysore Masala Dosa with 12% less from normal price";
alert("Free with Mysore Masala Dosa \n Apple Juice");
x = document.getElementById("an12");
x.style.color = "coral";
break;
case 5:
day = "Friday - Special - Set Dosa with 16% less from normal price";
alert("Free with Set Dosa\n Sapota Juice");
x = document.getElementById("an12");
x.style.color = "midnightblue";
break;
case 6:
day = "Saturday - Special - Cheese Dosa with 9% less from normal price";
alert("Free with Cheese Dosa\n Strawberry Juice");
x = document.getElementById("an12");
x.style.color = "darkorange";
break;
}
document.getElementById("an12").innerHTML = "Today is " + day;
}
< /script>

/*******/







Please click for Different Varieties / Types of Dosa

19)Continuing the above question, additionally display Dosa picture also. You're developing a website for a vegetable restaurant which is offering, daily one type of Dosa dish (seven days seven different types of dosa and free fruit juice) with special discount and one free fruit juice. On click of a button, system day must be picked and display the special Dosa item and free juice name fixed for that day through alert pop up and p - paragraph element display. P - paragraph display with different text color, each day one color. P - paragraph element id is "an13". USE SWITCH CASE STATEMENT. Choose correct option from below list. My heartfelt thanks for the Dosa Pictures used in this blog.

1.
< script >
function dayspecialitem1()
{
var day;
switch (new Date().getDay())
{
case 0:
day = "Sunday - Special - Butter Masala Dosa with 10% less from normal price";
alert(Free with Butter Masala Dosa \n Mosambi Juice);
x = document.getElementById("an13");
x.style.color = "black";
document.getElementById("dosa1").style.display = "block";
break;
case 1:
day = "Monday - Special - Wheat or Atta Dosa with 12% less from normal price";
alert("Free with Wheat or Atta Dosa \n Orange Juice");
x = document.getElementById("an13");
x.style.color = "maroon";
document.getElementById("dosa2").style.display = "block";
break;
case 2:
day = "Tuesday - Special - Neer Dosa with 15% less from normal price";
alert("Free with Neer Dosa \n Grape Juice");
x = document.getElementById("an13");
x.style.color = "darkorange";
document.getElementById("dosa3").style.display = "block";
break;
case 3:
day = "Wednesday - Special - Ghee Dosa with 14% less from normal price";
alert("Free with Ghee Dosa \n Pine Apple Juice");
x = document.getElementById("an13");
x.style.color = "hotpink";
document.getElementById("dosa4").style.display = "block";
break;
case 4:
day = "Thursday - Special - Mysore Masala Dosa with 12% less from normal price";
alert("Free with Mysore Masala Dosa \n Apple Juice");
x = document.getElementById("an13");
x.style.color = "coral";
document.getElementById("dosa5").style.display = "block";
break;
case 5:
day = "Friday - Special - Set Dosa with 16% less from normal price";
alert("Free with Set Dosa\n Sapota Juice");
x = document.getElementById("an13");
x.style.color = "midnightblue";
document.getElementById("dosa6").style.display = "block";
break;
case 6:
day = "Saturday - Special - Cheese Dosa with 9% less from normal price";
alert("Free with Cheese Dosa\n Strawberry Juice");
x = document.getElementById("an13");
x.style.color = "darkorange";
document.getElementById("dosa7").style.display = "block";
break;
}
document.getElementById("an13").innerHTML = "Today is " + day;
}
< /script>

/*******/


2.
< script >
function dayspecialitem1()
{
var day;
switch (new Date().getDay)
{
case 0:
day = "Sunday - Special - Butter Masala Dosa with 10% less from normal price";
alert("Free with Butter Masala Dosa \n Mosambi Juice");
x = document.getElementById("an13");
x.style.color = "black";
document.getElementById("dosa1").style.display = "block";
break;
case 1:
day = "Monday - Special - Wheat or Atta Dosa with 12% less from normal price";
alert("Free with Wheat or Atta Dosa \n Orange Juice");
x = document.getElementById("an13");
x.style.color = "maroon";
document.getElementById("dosa2").style.display = "block";
break;
case 2:
day = "Tuesday - Special - Neer Dosa with 15% less from normal price";
alert("Free with Neer Dosa \n Grape Juice");
x = document.getElementById("an13");
x.style.color = "darkorange";
document.getElementById("dosa3").style.display = "block";
break;
case 3:
day = "Wednesday - Special - Ghee Dosa with 14% less from normal price";
alert("Free with Ghee Dosa \n Pine Apple Juice");
x = document.getElementById("an13");
x.style.color = "hotpink";
document.getElementById("dosa4").style.display = "block";
break;
case 4:
day = "Thursday - Special - Mysore Masala Dosa with 12% less from normal price";
alert("Free with Mysore Masala Dosa \n Apple Juice");
x = document.getElementById("an13");
x.style.color = "coral";
document.getElementById("dosa5").style.display = "block";
break;
case 5:
day = "Friday - Special - Set Dosa with 16% less from normal price";
alert("Free with Set Dosa\n Sapota Juice");
x = document.getElementById("an13");
x.style.color = "midnightblue";
document.getElementById("dosa6").style.display = "block";
break;
case 6:
day = "Saturday - Special - Cheese Dosa with 9% less from normal price";
alert("Free with Cheese Dosa\n Strawberry Juice");
x = document.getElementById("an13");
x.style.color = "darkorange";
document.getElementById("dosa7").style.display = "block";
break;
}
document.getElementById("an13").innerHTML = "Today is " + day;
}
< /script>

/*******/


3.
< script >
function dayspecialitem1()
{
var day;
switch (new Date().getDay())
{
case 0:
day = "Super Sunday - Special - Butter Masala Dosa with 10% less from normal price";
alert("Free with Butter Masala Dosa \n Mosambi Juice");
x = document.getElementById("an13");
x.style.color = "black";
document.getElementById("dosa1").style.display = "block";
break;
case 1:
day = "Monday - Special - Wheat or Atta Dosa with 12% less from normal price";
alert("Free with Wheat or Atta Dosa \n Orange Juice");
x = document.getElementById("an13");
x.style.color = "maroon";
document.getElementById("dosa2").style.display = "block";
break;
case 2:
day = "Tuesday - Special - Neer Dosa with 15% less from normal price";
alert("Free with Neer Dosa \n Grape Juice");
x = document.getElementById("an13");
x.style.color = "darkorange";
document.getElementById("dosa3").style.display = "block";
break;
case 3:
day = "Wednesday - Special - Ghee Dosa with 14% less from normal price";
alert("Free with Ghee Dosa \n Pine Apple Juice");
x = document.getElementById("an13");
x.style.color = "hotpink";
document.getElementById("dosa4").style.display = "block";
break;
case 4:
day = "Thursday - Special - Mysore Masala Dosa with 12% less from normal price";
alert("Free with Mysore Masala Dosa \n Apple Juice");
x = document.getElementById("an13");
x.style.color = "coral";
document.getElementById("dosa5").style.display = "block";
break;
case 5:
day = "Friday - Special - Set Dosa with 16% less from normal price";
alert("Free with Set Dosa\n Sapota Juice");
x = document.getElementById("an13");
x.style.color = "midnightblue";
document.getElementById("dosa6").style.display = "block";
break;
case 6:
day = "Saturday - Special - Cheese Dosa with 9% less from normal price";
alert("Free with Cheese Dosa\n Strawberry Juice");
x = document.getElementById("an13");
x.style.color = "darkorange";
document.getElementById("dosa7").style.display = "block";
break;
}
document.getElementById("an13").innerHTML = "Today is " + day;
}
< /script>

/*******/









Different Types of Dosas. In this website, you will not only see beautiful pictures of Dosa, but also learn how to cook tasty dosas.

20) You're developing a Website for a School. Head Master of that School has decided to display and hide digital time on their website, but current time must be visible on click of a button - Click here for display of current time and another button - Click here to hide the timer . Time must be displayed through p - paragraph element with Id "timestart". Write a JavaScript. Below are the three options. Please choose the correct option and click submit button.

1.

Script for display of Timer

< script >

function displaytime()
{
document.getElementById("timestart").style.display= "block";
var d = new Date();
var t = d.toLocaleTimeString();
document.getElementById("timestart").innerHTML = "Now the TIME is: " + t;
}
< /script >

Script for hiding the Timer

< script >
function hidetime()
{
document.getElementById("timestart").style.display= "none";
}
< /script >
2.

Script for display of Timer

< script >

function displaytime()
{
document.getElementById("timestart").style.display= "visible";
var d = new Date();
var t = d.toLocaleTimeString();
document.getElementById("timestart").innerHTML = "Now the TIME is: " + t;
}
< /script >

Script for hiding the Timer

< script >
function hidetime()
{
document.getElementById("timestart").style.display= "none";
}
< /script >
3.

Script for display of Timer

< script >

function displaytime()
{
document.getElementByid("timestart").style.display= "block";
var d = new Date();
var t = d.toLocaleTimeString();
document.getElementById("timestart").innerHTML = "Now the TIME is: " + t;
}
< /script >

Script for hiding the Timer

< script >
function hidetime()
{
document.getElementById("timestart").style.display = "none";
}
< /script >




21) What is Math object in JavaScript . Write a script to round this number 100000.614 to nearest integer. Display the result through alert pop up and paragraph on the web page. P - Paragraph element name is "an15". Select correct option from the below list.

1.

The Math object method will allow us to perform only addition, substraction, multiplication and division mathematical calculations.


< script >
function roundnumber()
{
var num1 = 100000.614;
var roundnumber = math.round(num1);
alert("Number 100000.614 rounded to is: " + roundnumber);
document.getElementById("an15").innerHTML = "Number 100000.614 rounded to is: " + roundnumber;
}
< /script >

< button onclick="roundnumber()" title="Please click to proceed..." >Number rounded to nearest integer in JavaScript< /button >

2.

The Math object method will allow us to perform mathematical tasks and computations.


< script >
function roundnumber()
{
var num1 = 100000.614;
var roundnumber = Math.round(num1);
alert("Number 100000.614 rounded to is: " + roundnumber);
document.getElementById("an15").innerHTML = "Number 100000.614 rounded to is: " + roundnumber;
}
< /script >

< button onclick="roundnumber()" title="Please click to proceed..." >Number rounded to nearest integer in JavaScript< /button >

3.

The Math Object can do string operations also.


< script >
function roundnumber()
{
var num1 = 100000.614;
var roundnumber = Math.rnd(num1);
alert("Number 100000.614 rounded to is: " + roundnumber);
document.getElementById("an15").innerHTML = "Number 100000.614 rounded to nearest integer is: " + roundnumber;
}
< /script >

< button onclick="roundnumber()" title="Please click to proceed..." >Number rounded to nearest integer in JavaScript< /button >


22) What will be the output of the following Script.


< script >
function outputofvar()
{
var num1 = "2";
var num2 = "2";
var num3 = "0";
alert (num1 + num2 + num3);
document.getElementById("an16").innerHTML = "The output is: " + num1 + num2 + num3;
}
< /script >
< button onclick="outputofvar()" >Click to view output< /button>

Choose the correct one from below list and click Submit button.


1.
"2""2""0"

2.
220

3.
NaN


23) You're designing a website for a Mobile phone show room. They are telling you to change the text color "This model Mobile Phone is on SALE!" and display below underlined contents, on mouse hover and on mouse out event. On mouse hover color is Red and on mouse out color is Blue. Write a Script for the same.

This Mobile Phone is the latest one on the market with salient features.
It's the hot cake, being bought by several people all over the world!
Hurry up! stock is depleting.

Choose the correct one from below list and click Submit button.


1.

On mouse hover, text color change and display Script

< script >
function changeColor()
{
x = document.getElementById("an17");
x.style.color = "#ff0000";
y = document.getelementById("an18");
y.style.display ="block";
}
< /script >

On mouse out, text color change and hide Script

< script >
function onmouseOut()
{
x = document.getElementById("an17");
x.style.color = "blue";
document.getElementById("an18").style.display = "none";
}
< /script >

2.

On mouse hover, text color change and display Script

< script >
function changeColor()
{
x = document.getElementById("an17");
x.style.color = "#ff0000";
y = document.getElementById("an18");
y.style.display ="block";
}
< /script >

On mouse out, text color change and hide Script

< script >
function onmouseOut()
{
x = document.getElementById("an17");
x.style.color = "blue";
document.getElementById("an18").style.display = "none";
}
< /script >

3.

On mouse hover, text color change and display Script

< script >
function changeColor()
{
x = document.getElementById("an17");
x.style.color = "#ff0000";
y = document.getElementById("an18");
y.style.display ="block";
}
< /script >

On mouse out, text color change and hide Script

< script >
function onmouseOut()
{
x = document.getElementById("an17");
x.style.Color = "blue";
document.getElementById("an18").style.display = "none";
}
< /script >

This model Mobile Phone is on SALE!

23A) In continuation of question number 23, On mouse hover event, you have to display below shown Mobile phone picture also along with text content. You're designing a website for a Mobile phone show room. They are telling you to change the text color "This model Mobile Phone is on SALE!" and display below underlined contents, on mouse hover and on mouse out event. On mouse hover color is Red and on mouse out color is Blue. Write a Script for the same.

mobile phone picture

This Mobile Phone is the latest one on the market with salient features.
It's the hot cake, being bought by several people all over the world!
Hurry up! stock is depleting.

Choose the correct one from below list and click Submit button.


1.

On mouse hover, text color change and display Script

< script >
function changeColor1()
{
x = document.getElementById("an19");
x.style.color = "#ff0000";
y = document.getelementById("an20");
y.style.display ="block";
m = document.getElementById("mobilephone1");
m.style.display ="block";
m.style.border = "5px dotted deeppink";
}
< /script >

On mouse out, text color change and hide Script

< script >
function onmouseOut1()
{
x = document.getElementById("an19");
x.style.color = "blue";
document.getElementById("an20").style.display = "none";
}
< /script >

2.

On mouse hover, text color change and display Script

< script >
function changeColor1()
{
x = document.getElementById("an19");
x.style.color = "#ff0000";
y = document.getElementById("an20");
y.style.display ="block";
m = document.getElementById("mobilephone1");
m.style.display ="block";
m.style.border = "5px dotted deeppink";
}
< /script >

On mouse out, text color change and hide Script

< script >
function onmouseOut1()
{
x = document.getElementById("an19");
x.style.color = "blue";
document.getElementById("an20").style.display = "none";
}
< /script >

3.

On mouse hover, text color change and display Script

< script >
function changeColor1()
{
x = document.getElementById("an19");
x.style.color = "#ff0000";
y = document.getElementById("an20");
y.style.display ="block";
m = document.getElementById("mobilephone1");
m.style.display ="block";
m.style.border = "5px dotted deeppink";
}
< /script >

On mouse out, text color change and hide Script

< script >
function onmouseOut1()
{
x = document.getElementById("an19");
x.style.Color = "blue";
document.getElementById("an20").style.display = "none";
}
< /script >

This model Mobile Phone is on SALE!

24) Length property of String object demo. On click of a button, prompt dialog box pops up and user has to enter some content, script will display what is entered and count the number of characters. Output screen shots are below. Choose correct option from the list and click Submit button

1.

< script >
function stringobjdemo()
{
var yinput = prompt("Enter some text");
if (yinput != "")
{
alert("Your input: + yinput");
var x = yinput.length;
alert("Count of the content: " + x);
}
else
{
alert("You've not entered anything");
}
document.getElementById("inputtext").innerHTML = "Your input is: " + yinput;
document.getElementById("textlength").innerHTML = "Count of Your input " + yinput + " is: " + x;
}
< /script >

< button onclick="stringobjdemo()" >Click here< /button >

2.

< script >
function stringobjdemo()
{
var yinput = prompt("Enter some text");
if (yinput != "")
{
alert("Your input: " + yinput);
var x = yinput.length;
alert("Count of the content: " + x);
}
else
{
alert("You've not entered anything");
}
document.getElementById("inputtext").innerHTML = "Your input is: " + yinput;
document.getElementById("textlength").innerHTML = "Count of Your input " + yinput + " is: " + x;
}
< /script >

< button onclick="stringobjdemo()" >Click here< /button >

3.

< script >
function stringobjdemo()
{
var yinput = input("Enter some text");
if (yinput != "")
{
alert("Your input: " + yinput);
var x = yinput.length;
alert("Count of the content: " + x);
}
else
{
alert("You've not entered anything");
}
document.getElementById("inputtext").innerHTML = "Your input is: " + yinput;
document.getElementById("textlength").innerHTML = "Count of Your input " + yinput + " is: " + x;
}
< /script >

< button onclick="stringobjdemo()" >Click here< /button >


25) There is some text displayed on the website input box, user is free to change the content and copy the same. Display alert message "You have copied the text and free to use on your own" and DISPLAY THE CONTENT IN THAT INPUT BOX, also same message through paragraph must be displayed on the website. Select correct option from below list and click Submit button.

1.
< input type="text" oncopy="yourcopy()" value="Copy this text and see output" id="inputvalue" style="width: 250px;" />

< p id="copydemo">< /p>
< p id="copiedvalue">< /p>
< script >
function yourcopy()
{
var b = "You have copied the text and free to use on your own" ;
var b = document.getElementById("inputvalue").value;
document.getElementById("copydemo").innerHTML = a;
document.getElementById("copiedvalue").innerHTML = b;
alert(a);
alert(b);
} < /script >

2.
< input type="text" oncopy="yourcopy()" value="Copy this text and see output" id="inputvalue" style="width: 250px;" />
< p id="copydemo">< /p>
< p id="copiedvalue">< /p>
< script >
function yourcopy()
{
var a = "You have copied the text and free to use on your own" ;
var b = document.getElementById("inputvalue").value;
document.getElementById("copydemo").innerHTML = a;
document.getElementById("copiedvalue").innerHTML = b;
alert(a);
alert(b);
}
< / script >

3.
< input type="text" oncopy="yourcopy()" value="Copy this text and see output" id="inputvalue" style="width: 250px;" />
< p id="copydemo">< /p>
< p id="copiedvalue">< /p>
< script >
function yourcopy()
{
var a = "You have copied the text and free to use on your own" ;
var b = document.getElementById("inputvalue").value;
document.getElementByid("copydemo").innerHTML = a;
document.getElementById("copiedvalue").innerHTML = b;
alert(a);
alert(b);
}
< / script >


Will Continue... Good Luck!

Please click here to visit Google Small Business portal for further details. Thanks

Explore the Special offers and get support for your business to come online

Small businesses are the backbone of our economy and communities. Small businesses contribute for the well being of this globe. We know this is a difficult time for people everywhere, including for small business owners / sole proprietors. One day, small business may grow to big business. In this digital world, many people give orders online and want products delivered at their door step. We have gathered useful tips, trainings and resources to help your business to tackle this difficult times. Click here for solutions.

In what are the ways Google Small Business will support for your business development:

  1. Update your Business profile on Google
  2. Accept contactless digital payments
  3. Update your Google Ads campaign
  4. Run your business remotely

All the best animated image for free download and share on your social media network

>

"Strength and growth come only through continuous effort and struggle." Life inspiring quote by Napoleon Hill



Hello my Love! How're you doing? Baby don't hurt me

Happy Wedding Anniversary! Wishing you both a loving life!

40% off on your Cloud hosting solution

Lear JavaScript OOP - Object Oriented Programming - a primer for Web Development

Since the launch of Gmail in 2004, and Google Docs two years later, we’ve been building flexible, helpful and innovative solutions that allow people to connect, create and collaborate securely — from anywhere on the planet and on any device. When we debuted Google Workspace last October, we not only introduced a new brand, but also our vision for a single, integrated experience for everyone: Everything you need to get anything done, now in one place. Across apps like Gmail, Chat, Calendar, Drive, Docs, Sheets, Meet and more, our consumer, enterprise and education users choose Google Workspace to stay in touch, share ideas and get more done together every day. Now Google Workspace is for everyone and all. Please click to know more.

"Success never comes to look for you while you wait around. You've got to get up and work at it to make your dreams come true." Motivational quote by Poh Yu Khing

Android 14 is live in AOSP
Android 14 -The latest Android and Google Play news for app and game developers.

Today we're releasing Android 14 and pushing the Android 14 source to the Android Open Source Project (AOSP). Android 14 is designed to improve your productivity as developers while enhancing performance, privacy, security, and customization for users.
Android 14 is rolling out to select Pixel devices starting today, and will be available later this year on some of your favorite devices from Samsung Galaxy, iQOO, Nothing, OnePlus, Oppo, Realme, Sharp, Sony, Tecno, vivo and Xiaomi. Learn more...
Thank you for taking the time to take Android 14 for an early spin though our developer preview and beta programs, sharing your feedback, and making sure your apps deliver a great experience on Android 14. Making Android work well for each and every one of the billions of Android users is a collaborative process between us, Android hardware manufacturers, and you, our developer community.


Make it your mission to magnify people's strengths, not to highlight their weaknesses.
- Lorri Faye


Comments

  1. Nice article I was really impressed by seeing this blog, it was very interesting and it is very useful for me. Informative blog! It was very useful for me. Thanks for sharing.
    Also Visits
    Hire Android Application Developer
    Mobile Application Development Company
    Develop an eLearning App Like Duolingo?

    ReplyDelete
  2. Really Good tips and advises you have just shared. Thank you so much for taking the time to share such a piece of nice information. Looking forward for more views and ideas, Keep up the good work! Visit here for Product Engineering Services | Product Engineering Solutions.

    ReplyDelete

Post a Comment

Popular posts from this blog

Java Script questions and answers demo page 2

Google Career Certificates: Vishnu