css micro
css micro
Output:
The entry is a palindrome.
The entry is a palindrome.
Entry is not a palindrome.
Q6. Write a JavaScript that find and displays number of
duplicate values in an array.
<!DOCTYPE html>
<html>
<body>
<h3>Finding duplicate values in a JavaScript array</h3>
<p>Here, we will find the repeating values in the given
array.</p>
<p>Original array: [6, 9, 15, 6, 13, 9, 11, 15]</p>
<p id="result"></p>
<script>
//simple traversal method
let array = [6, 9, 15, 6, 13, 9, 11, 15];
let index = 0, newArr = [];
const length = array.length; // to get length of array
function findDuplicates(arr) {
for (let i = 0; i < length - 1; i++) {
for (let j = i + 1; j < length; j++) {
if (arr[i] === arr[j]) {
newArr[index] = arr[i];
index++;
}}}
return newArr;
}
document.getElementById('result').innerHTML = 'Duplicate
values are: <b>' + findDuplicates(array) + '</b>';
</script>
</body>
</html>
Output :
Finding duplicate values in a JavaScript array
Here, we will find the repeating values in the given array.
Original array: [6, 9, 15, 6, 13, 9, 11, 15]
Duplicate values are: 6,9,15
Q7. Write a function that prompts the user for a color and
uses what they select to set the background color of the new
webpage opened .
<!DOCTYPE html> <html lang="en">
<head> <meta charset="utf-8">
<title>Change the Background Color with JavaScript</title>
<script>
// Function to change webpage background color
function changeBodyBg(color){
document.body.style.background = color;
}
// Function to change heading background color
function changeHeadingBg(color){
document.getElementById("heading").style.background = color;
}
</script> </head> <body>
<h1 id="heading">This is a heading</h1>
<p>This is a paragraph of text.</p>
<hr> <div>
<label>Change Webpage Background To:</label>
<button type="button"
onclick="changeBodyBg('yellow');">Yellow</button>
<button type="button"
onclick="changeBodyBg('lime');">Lime</button>
<button type="button"
onclick="changeBodyBg('orange');">Orange</button>
</div> <br> <div>
<label>Change Heading Background To:</label>
<button type="button"
onclick="changeHeadingBg('red');">Red</button>
<button type="button"
onclick="changeHeadingBg('green');">Green</button>
<button type="button"
onclick="changeHeadingBg('blue');">Blue</button>
</div>
</body>
</html>
Q8. Develop JavaScript to convert the given character to
Unicode and vice versa.
<html> <head> </head> <body>
<h2>Convert Unicode values to characters in JavaScript.</h2>
<h4>Converting single Decimal Unicode value to character
using the <i> fromCharCode() </i> method.</h4>
<p id = "output"> </p>
<script>
let output = document.getElementById("output");
// converting different decimal values to characters
let value = 69;
let
char = String.fromCharCode( value );
output.innerHTML += value + " to unicode character is : " +
char + " <br/> ";
char = String.fromCharCode( 97 );
output.innerHTML += 97 + " to unicode character is : " + char +
" <br/> ";
</script> </body> </html>
Q9. List ways of Protecting your webpage and describe
any one of them.
At the time of the rapid digital transformation of the global
economy, companies communicate with their clients either
through social media channels or using their websites. By
opening the company’s website users can view all recent
updates, buy products or services, contact the company’s
representatives, get special offers, etc.
confirm()
Use the confirm() function to take the user's confirmation before
starting some task. For example, you want to take the user's
confirmation before saving, updating or deleting data.
Syntax: bool window.confirm([message]);
The confirm() function displays a popup message to the user
with two buttons, OK and Cancel. The confirm() function returns
true if a user has clicked on the OK button or returns false if
clicked on the Cancel button. You can use the return value to
process further.
var userPreference;
if (confirm("Do you want to save changes?") == true) {
userPreference = "Data saved successfully!";
} else {userPreference = "Save Cancelled!";}
<html> <head>
<title> Array</title>
</head> <body> <script>
var arr1 = [ “Red”, “red”, “Blue”, “Green”]
document.write(“Before sorting arra1=” + arr1);
document.write(“<br>After sorting arra1=” + arr1.sort());
</script> </body> </html>
Q15. Write a script for creating following frame structure :
Fruits, Flowers and Cities are links to the webpage
fruits.html, flowers.html, cities.html respectively. When these
links are clicked corresponding data appears in “FRAME3”.
<html> <head>
<title>Frame Demo</title>
</head> <body>
<table border="1">
<tr>
<td align="center" colspan="2">
FRAME 1
</td> </tr> <tr> <td>
FRAME 2
<ul> <li>
<a href="fruits.html" target="mainframe">FRUITS</a>
</li> <li>
<a href="flowers.html" target="mainframe">FLOWERS</a>
</li> <li>
<a href="cities.html" target="mainframe">CITIES</a>
</li> </ul> </td> <td>
FRAME 3<BR>
<iframe name="mainframe"></iframe>
</td> </tr>
</table> </body> </html>
Q 1. What do you mean by scripting language ? Give one
example.
Script is a small piece of program that can add interactivity to
the website
Scripting language is a form of programming language that is
usually interpreted rather than compiled.
There are 2 types of scripting language.
1. Client Side scripting language -- eg javascript, VBscript
2. Server side scripting language – JSP,ASP,PHP
Q 2. List out any 6 features of java script.
• Scripting Language. JavaScript is a lightweight scripting
language made for client-side execution on the browser. ...
• Interpreter Based.
• Event Handling.
• Light Weight.
• Case Sensitive.
• Control Statements.
• Objects as first-class citizens.
ii. fromCharCode()
The method fromCharCode allows us to easily convert any
Unicode value into a character. It's the opposite of the method
charCodeAt().
The method accepts one required argument(the Unicode value)
and you can also pass multiple Unicodes if you want to make a
word or a sentence.
The method is accessed through the object String with dot
notation.
Here is the example:
String.fromCharCode(74); //returns "J"
String.fromCharCode(118); //returns "v"
//multiple arguments.
String.fromCharCode(74, 65, 118, 65); //returns "JAvA"
Q 12. What is the difference between text field and text area.
Give its syntax.
JTextField
• A JTextFeld is one of the most important components
that allow the user to an input text value in a single line
format.
• A JTextField will generate an ActionListener interface
when we trying to enter some input inside it.
• The JTextComponent is a superclass
of JTextField that provides a common set of methods
used by JTextfield.
• The important methods in the JTextField class
are setText(), getText(), setEnabled(), etc.
JTextArea
• A JTextArea is a multi-line text component to display
text or allow the user to enter text.
• A JTextArea will generate a CaretListener interface.
• The JTextComponent is a superclass of JTextArea that
provides a common set of methods used by JTextArea.
• The important methods in the JTextArea class
are setText(), append(), setLineWrap(),
setWrapStyleWord(), setCaretPosition(), etc.
Q 13. What do you mean by intrinsic function ?
An intrinsic function is a function that performs a mathematical,
character, or logical operation. You can use intrinsic functions to
make reference to a data item whose value is derived
automatically during execution.
Data processing problems often require the use of values that are
not directly accessible in the data storage associated with the
object program, but instead must be derived through performing
operations on other data. An intrinsic function is a function that
performs a mathematical, character, or logical operation, and
thereby allows you to make reference to a data item whose value
is derived automatically during execution.
The intrinsic functions can be grouped into six categories, based
on the type of service performed:
• Mathematical
• Statistical
• Date/time
• Financial
• Character-handling
• General
You can reference a function by specifying its name, along with
any required arguments, in a PROCEDURE DIVISION
statement.
Functions are elementary data items, and return alphanumeric
character, national character, numeric, or integer values.
Functions cannot serve as receiving operands.
Q3. Write a program for switch case statement in java script
to print months .
<html>
<script language="JavaScript">
<!--
function getMonthString(num)
{
var month; //Create a local variable to hold the string
switch(num)
{
case 0: month="January"; break; case 1: month="February"; break;
case 2: month="March"; break; case 3: month="April"; break;
case 4: month="May"; break; case 5: month="June"; break;
case 6: month="July"; break; case 7: month="August"; break;
case 8: month="September"; break; case 9: month="October"; break;
case 10: month="November"; break; case 11: month="December"; bre
ak;
default: month="Invalid month";
} return month;
}
theDate = new Date();
document.write("The month is ",getMonthString(theDate.get
Month()));
-->
</script> </html>
Q4. Explain looping in java script.
Looping in programming languages is a feature that facilitates
the execution of a set of instructions/functions repeatedly while
some condition evaluates to true. For example, suppose we want
to print “Hello World” 10 times. This can be done in two ways as
shown below:
Iterative Method: The iterative method to do this is to write the
document.write() statement 10 times.
Cookie Session