Download JavaScript Practice Assignments and more Quizzes Programming Languages in PDF only on Docsity!
A
G
E
Operators:
- Practice expression with operators
- Study Operator precedence (https://developer.mozilla.org/en- US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence) var x = ++num //take num = 20 var y = num++ //take num = 10
- Try this in browser: (true == false) > 2
- Practice Post & Pre Increment(++) & decrement(--). Try all below questions on your own, then execute in browser to check your progress. var val = 23; var t = ++val; val++; console.log(val) console.log(t); var numVal = 30; var u = --numVal; numVal++; console.log(u); console.log(numVal); var a = 40; var b = a++; b++; console.log(a); console.log(b); var f = 50; var g = f++; g--; console.log(g); console.log(f); var val = 10; val++; var h = --val; h++; console.log(h); console.log(val);
A
G
E
var num = 20; num++; var t = ++num; num++; --num console.log(num, t); var num = 10; --num; var y = ++num + 10; --y; console.log(y); console.log(num); var num = 30; ++num; num++ - 10; console.log(num);
Implicit coercion: Practice questions on implicit coercion
- Try these first, then execute in browser to check progress. console.log('A' - 1);// console.log('A' + 1);// console.log(2 + '2' + '2');// console.log('hello' + 'world' + 89);// console.log('hello' - 'world' + 89);// console.log('hello' + 78);// console.log('78' - 90 + '2');// console.log(2 - '2' + 90);// console.log(89 - '90' / 2);//
Datatypes:
- Extract first five letters from a string ('gfuh ieiuei')
- Get the length of a string and make it uppercase ('hduej dij')
- Take a string, make it uppercase and trim it (' biji jdo ')
- Revise type of each datatype
- Replace specified word in a string ('', '')
- Random statements in implicit coersion e.g. (89 + 'hello' + 90 / 9)
- Try this: (2 + '2' + null);
- Find the duplicate in a string() (use array)
- Reverse a string (use array method)
- Find the highest and lowest value in array
- Sorting of an array (employee data structure)
A
G
E
- Create a ATM Machine with below features. balance & query withdraw (amount) change pin mini statement saving & current acc. print receipt enter pin number
- Given alphabet is vowel or consonant
- Calculate Simple interest ((p/r * t) * 100 )
- Given year leap year or not
- 0 - 6 display day week depending upon what user is entering (0-> sunday)
Loops: Use loops, conditional statements, take input from user for below task.
- multiplication table (ask number from user)
- sum of digits (123: 1 + 2 + 3 = 6) or (1234 : 1 + 2 + 3 + 4 = 10)
- palindrome string (aca: aca is a palindrome, abc: cba is not a palindrome)
- display even numbers up to n number (ask user for number)
- keep asking user for the input, whether char is vowel or consonant
- count of even and odd number from 1 to 999
- count occurrence of a particular character in a string (hello: count of l is 2)
- sum and average of array elements [1, 9, 8];
- largest number in an array (do with loops)
- From 1 to 100, print "foo" if multiple of 3, "bar" if multiple of 5, if multiple of both display "hello" or else print the number e.g. 1 2 foo 4 bar foo
Type conversion
- (+infinity , - infinity) in js
- Practice type conversion Boolean, string, numbers
- Add only even numbers in an array (array elements to be input by user)
- Found an element in array [10, 78, 90] return 90 otherwise exit from an array.
Regex
Find first letter in a string is uppercase or lowercase through regex (e.g. 'hello world') Take input from user as name and display it( urvashi :urvashi) Find count of vowels in a string (aeiou)
A
G
E
Find a digit in a string (e.g: hello789: 789) Find all the consonants in string Check whether a given value is alphanumeric or not (e.g: hello789: yes) email regex, try test method on this check given value(string) contains alpha, underscore, dash check given url is valid or not (e.g. http://www.amazon.in)
More Practice task on arrays & loops
- Ask array elements from user Smallest number in an array Biggest of even number in an array ([10, 12, 90, 93, 7]): biggest even number is 90 Add two array [10,20,30] + [1,2,3]: [11, 22, 33] Reverse an array(with loops) [10, 78, 0]: [0, 78, 10] Remove duplicate items from an array [10, 50,20 67, 10, 20]: remove 10, 20 Find duplicate values in an array.(display index of duplicate values e.g. 0,2,4,5) Find difference/subtraction in 2 arrays //[12, 56, 789] - [12, 56, 789]: [0, 0, 0] Ask user, remove a specific element from an array [12, 56, 89]: remove 1 element on click of a button, add random element to an array [12] array, check given elements palindrome or not [124, 121, 900, 565] array, for each element multiply by 2 [1, 2, 4]: [2, 4, 8] multiply 2 array [1, 2, 3 ] * [1, 1, 1 ]: [1, 2, 3]
Scope:
- Try scope create a method add, subtract ,multiply
Form
Create a form and validate it: email, contact, name, age, designation, select multiple files
DOM & BOM
Timing events (setTimeInterval(), setTimeout()) Fetch the index.html part of the current url Revise DOM & BOM
Timing Events:
- Create a clock show locale time (localestring) and display it in UI
A
G
E
Round off all the decimal numbers in an array and sum all the values [9.8, 9.7, 4.5, 3.4] Get all the person name based on age greater than and equal to 18, eligible to vote [{ firstName: 'joe', age: 24 }, { firstName: 'alina', age: 12 }, { firstName: 'alex', age: 20 } ] Sum all the elements of an array [90, 89, 56, 45] Check element is odd or even in an array [90, 89, 56, 45] Sum of all the salaries and display final sum value [{ salary: 56000, id: 1 }, { salary: 90000, id: 2 }] Concatenation of all array elemets ['pink', 'blue', 'green', 'red']: 'pinkbluegreenred'
Class
- Create a class Car: city(), specialFeature() name, brand, color, manufactureYear
- Create a class Book: type_of_book() no. of pages, type of pages, author
- Create a class Animal: walk(), eat(), climb() gender, name, disease
A
G
E
Inheritance :
- Create parent class: Electronics (methods: name, version, company name) and child class(laptop, ipad, mobile, tablet): create methods” configuration, price()
Advance Task (based on es6)
1.Symmetric difference of 2 arrays const arrOne = [{ id: 20, name: 'alex' }, { id: 30, name: 'alina' }] const arrTwo = [{ id: 40, name: 'hello' }, { id: 30, name: 'world' } ] result = [{ id: 20, name: 'alex' }, { id: 40, name: 'hello' }] Result = [{ id: 40, name: 'hello' },{ id: 40,