Monday, April 8, 2024

javascript questions


 1.Write Java Script program to display date and time.

 <html>

<head>


    <title>date</title>

</head>

<body>

<script type="text/javascript">

var m = new Date();

var x = m.getDate() +" "+ m.getMonth() +" "+ m.getFullYear() + " " + m.getHours() +

":" + m.getMinutes();

document.write(x);

</script>

</html>

Program 2. An array contains some string data. Print them using javascript


<html>

<head> <title>array</title>

</head>

<body>

<script>

var  a= new Array(5);

a=["ram","hari","sita","rita","gita"];

document.write(a);

</script>

</body>

</html>

3. An array contains some data. Print them in reverse order.[use array.reverse() method].

<html>

<head> <title>array</title>

</head>

<body>

<script>

var  a= new Array(5);

a=["ram","hari","sita","rita","gita"];

document.write(a.reverse());

</script>

</body>

</html>

4.Write a program to insert a string "welcome to nepal" via form object getElementById() method.Use paragraph with id.

<html>

<head> <title>array</title>

</head>

<body>

<p id="result"> </p>

<script>

document.getElementById("result").innerHtml="welcome to nepal";

</script>

</body>

</html>






No comments:

Post a Comment

OOPS

   paradigm refers to a style or approach to solving problems and organizing code in a particular way. It dictates how developers think abo...