Skip to content

Latest commit

 

History

History
147 lines (103 loc) · 5.29 KB

File metadata and controls

147 lines (103 loc) · 5.29 KB
Learn more from cyberdude networks.

Frequently asked interview question - (FOR PRACTICE)

Please note that, video materials are only available in Tamil (தமிழ்), code solutions with explanations are available in English.

Rules to be followed:

  1. Solve programmatically.
  2. If a solution can be solved in other methods, give it a try. Remember, there is always several ways to do things.
  3. Try to solve it yourself, if you got struck, no problem. Google it Yourself. At last resort, see the solution of us.
  4. Code with fun, Happy Hacking.

Let's start - Solve these:

  1. Create an Array object - (In Atleast 3 methods) - [🎬 Video] [Solution]

  2. Take the below array and copy it using the slice method and the for loop method. - [🎬 Video] [Solution]

    var array = [1, 2, 3, 4, 5];
  3. Empty this array: - [🎬 Video] [Solution]

    var array = [1, 2, 3, 4, 5];
  4. What type is an Array set to? - [🎬 Video] [Solution]

  5. How can you check if something is an Array? - [🎬 Video] [Solution]

  6. Add an item to the end of an array. - [🎬 Video] [Solution]

  7. Find the index position of d in this array - [🎬 Video] [Solution]

    var arr = ["a", "b", "c", "d"];
  8. What will be returned if you look for the index of something that does not exist? - [🎬 Video] [Solution]

  9. Write a function to check if milk exists in your array. - [🎬 Video] [Solution]

    var items = ["milk", "bread", "sugar"];
  10. Now you've found milk exists add some code to find the index of milk and remove that item. - [🎬 Video] [Solution]

  11. List the ways to loop over an array. - [🎬 Video] [Solution]

  12. Write some code to put these numbers in order (Ascending & Descending) - [🎬 Video] [Solution]

    var numbers = [1, 12, 2, 23, 77, 7, 33, 5, 99, 234];
  13. Write some code to place this list in alphabetical order - [🎬 Video] [Solution]

    var p = ["a", "z", "e", "y"];
  14. What is the length of these arrays - [🎬 Video] [Solution]

    var arr1 = [, , ,];
    
    var arr2 = new Array(3);
    
    var arr3 = [1, 2, 3, 4, 5];
    
    var array = [
      [1, 2, 3],
      [4, 5, 6],
    ];
  15. What are the results of these splice and slice methods - [🎬 Video] [Solution]

    var a = ["zero", "one", "two", "three"];
    var names = ["jason", "john", "peter", "karen"];
    
    var sliced = a.slice(1, 3);
    var spliced = names.splice(1, 3);
  16. What are the console logs of these shift and unshift methods - [🎬 Video] [Solution]

    var a = [];
    
    // We take an empty array and
    
    a.unshift(1);
    a.unshift(22);
    var b = console.log(a);
    a.shift();
    var c = console.log(a);
    a.unshift(3, [4, 5]);
    var d = console.log(a);
    a.shift();
    var e = console.log(a);
    a.shift();
    var f = console.log(a);
    a.shift();
    var g = console.log(a);
  17. Using reduce add all these numbers - [🎬 Video] [Solution]

    var numbers = [1, 2, 3, 4, 5, 6];
  18. Flatten this array to one single array using reduce - [🎬 Video] [Solution]

    var array = [
      [0, 1],
      [2, 3],
      [4, 5],
    ];
  19. Filter this array to return just the dogs - [🎬 Video] [Solution]

    var animals = [
      { name: "Jason", species: "rabbit" },
      { name: "Jessica", species: "dog" },
      { name: "Jacky", species: "owl" },
      { name: "Luke", species: "fish" },
      { name: "Junior", species: "rat" },
      { name: "Thomas", species: "cat" },
    ];
  20. Using array in Question 19 use map function to return all the species. - [🎬 Video] [Solution]