Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
21 views

Explain bitwise operators available in JavaScript

The document outlines various JavaScript concepts and tasks, including bitwise operators, getter and setter functions, output display methods, and logical operators. It also includes practical exercises such as creating objects, using loops, validating user accounts, and manipulating arrays and strings. Additionally, it covers features of JavaScript, data types, and methods for performing calculations and string manipulations.

Uploaded by

letscookbrba
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

Explain bitwise operators available in JavaScript

The document outlines various JavaScript concepts and tasks, including bitwise operators, getter and setter functions, output display methods, and logical operators. It also includes practical exercises such as creating objects, using loops, validating user accounts, and manipulating arrays and strings. Additionally, it covers features of JavaScript, data types, and methods for performing calculations and string manipulations.

Uploaded by

letscookbrba
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

1.

Explain bitwise operators available in JavaScript

2. Explain getter and setter in JavaScript

3. State the ways to display the output in JavaScript

4. List the logical operators in JavaScript with description


5. Write JavaScript to create object “student”with properties roll number

,name,branch,year,Delete branch property and display remaining properties of student

object.

6. Explain Object creation in JavaScript using ‘new’ keyword with adding properties and

methods with example

7. Write a JavaScript for loop that will iterate from 1 to 15. For each iteration it will check if the

current number is obb or even and display a message to the screen Sample Output: “1 is

odd” “2 is even” ….............


8. State the use of method in JavaScript with the help of suitable example.

9. List & explain datatypes in JavaScript

10. Write a simple calculator program using switch case in JavaScript. 1

11. State the features of JavaScript.


12. Write a JavaScript program to check whether entered number is prime or not.

13. Write a JavaScript program to validate user accounts for multiple set of user ID and

password (using switch case statement).

<body>

Enter your User ID

<input type="text" id="id">

<br><br>

Enter your Password

<input type="password" id="pass">

<br><br>

<input type="submit" onclick="check()">

<br><br>

<p id="display"></p>

<script>

function check() {

var uid = document.getElementById('id').value;


var pass = document.getElementById('pass').value;

switch(uid){

case "darshan.khapekar@vpt.edu.in":

if(pass == "darshan@123"){

document.getElementById('display').innerHTML = "Valid User";

break;

case "prashant.yelurkar@vpt.edu.in":

if(pass == "prashant@123"){

document.getElementById('display').innerHTML = "Valid User";

break;

case "konisha.thakare@vpt.edu.in":

if(pass == "konisha@123"){

document.getElementById('display').innerHTML = "Valid User";

break;

default:

document.getElementById('display').innerHTML = "Invalid User";

14. Differentiate between For-loop and For-in loop.


15. Write a JavaScript to checks whether a passed string is palindrome or not.

16. Define a function with example.

18. List form events.

19. Define array in JavaScript with example.


20. Write the use of following String methods:

a) charCodeAt()

b) fromCharCode()

21. Explain calling a function with arguments in JavaScript with example.

22. Differentiate between push() and join() method of array object with respect to

use,syntax,return value and example.


23. Write a Javascript code to perform following operation on string (Use split() method) Input

string : Sudha Narayana Murthy” Display output as First Name:Sudha Middle Name:

Narayana Last Name: Murthy

24. Explain splice() method of array object with syntax and example.
25. Write a program using sort method of array object.

26. Write a JavaScript program that will display current date in DD/MM/YYYY format.

</head>

<body>

<script>

var d=new Date();

var currentDate=d.getDate()+'/'+(d.getMonth()+1)+'/'+d.getFullYear()

document.write(currentDate)

</script>

</body>

</html>

27. Write a JavaScript program that will remove the duplicate element from an Array.
<script>
let arr = ["scale", "happy", "strength", "peace", "happy", "happy"];
function removeDuplicates(arr) {
let unique = [];
for(var i of arr) {
if(uniqueArr.indexOf(i) === -1)
{
uniqueArr.push(i);
}
}
document.write(uniqueArr);
}
document.write(removeDuplicates(arr));
</script>
</body>
</html>

28. Write a JavaScript program that will display list of student in ascending order according to

the marks & calculate the average performance of the class.

<script>

var students = [["Amit", 70],["Sumit", 78],["Abhishek", 71],];

var Avgmarks = 0;

for (var i = 0; i < students.length; i++) {

Avgmarks += students[i][1];

for (var j = i + 1; j < students.length; j++) {

if (students[i] > students[j]) {

a = students[i];

students[i] = students[j];

students[j] = a

var avg = Avgmarks / students.length;

document.write("Average grade: " + Avgmarks / students.length);

document.write("<br><br>");

for (i = 0; i < students.length; ++i){

document.write(students[i]+"<br>")

</script>

29. Write and explain a string functions for converting string to number and number to string.
30. Differentiate between concat( ) & join( ) methods of array object.

31. Write a JavaScript function to check the first character of a string is uppercase or not.
<script>
function upper_case(str)
{
regexp = /^[A-Z]/;
if (regexp.test(str))
{
document.write("String's first character is uppercase");
}
else
{
document.write("String's first character is not uppercase");
}
}
upper_case('Abcd');
</script>

32. Write a JavaScript function to merge two array & removes all duplicate values.
function mergearr(arr1, arr2)
{
// merge two arrays
var arr = arr1.concat(arr2);
var uniqueArr = [];
// loop through array
for(var i of arr) {
if(uniqueArr.indexOf(i) === -1)
{
uniqueArr.push(i);
}
}
document.write(uniqueArr);
}
var array1 = [1, 2, 3,6,8];
var array2 = [2, 3, 5,56,78,3]
mergearr(array1, array2);

33. Write a javascript function that accepts a string as a parameter and find the length of the

string.

function len(text)

return (text.length);

document.getElementById("demo").innerHTML = "length of string="+len("Information");

34. Develop javascript to convert the given character to unicode and vice-versa.

var x="HELLO";

document.writeln("<br>"+x.charCodeAt(4));

var res = String.fromCharCode(72, 69, 76, 76, 79);

document.write(res);

</script>

35. Write a javascript function to generate Fibonacci series till user defined limit.

function fibonacci(num)

var x = 0;

var y = 1;

var z;

var i = 0;

document.write(x);

document.write("<br>"+y);

for (i = 2; i < num; i++)

{
z = x + y;

x = y;

y = z;

document.write("<br>"+y);

var num = parseInt(prompt('Enter the number of terms: '));

answer = fibonacci(num);

</script>

var a=0;

var b=1;

var num=parseInt(prompt("Enter a number"));

for(var i=1;i<=num;i++)

document.write(a+" ");

var c=a+b;

a=b;

b=c;

36. Write a Java Script code to display 5 elements of array in sorted order.

37. Define objects and write different ways to create an Object with example.

38. Write a JavaScript to demonstrate the use of Checkbox with example.

39. Write JavaScript that initializes an array called Colors with the names of 3 Colors and

display array elements.

40. Write HTML code to design a form that display two textboxes for accepting two

numbers,one textbox for accepting result and two buttons as ADDITION and

SUBTRACTION.Write proper JavaScript such that when the user clicks on any one of the

button,respective operation will be performed on two numbers and result will be displayed
in result textbox.

You might also like