
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 8591 Articles for Front End Technology

705 Views
We are required to write a JavaScript function that takes in three argument, namely:day, month and year. Based on these three inputs, our function should find the day of the week on that date.For example: If the inputs are −day = 15, month = 8, year = 1993OutputThen the output should be −const output = 'Sunday'ExampleThe code for this will be −const dayOfTheWeek = (day, month, year) => { // JS months start at 0 return dayOfTheWeekJS(day, month - 1, year); } function dayOfTheWeekJS(day, month, year) { const DAYS = [ 'Sunday', ... Read More

532 Views
The power of the string is the maximum length of a non−empty substring that contains only one unique character.We are required to write a JavaScript function that takes in a string and returns its power.For example −const str = "abbcccddddeeeeedcba"Then the output should be 5, because the substring "eeeee" is of length 5 with the character 'e' only.ExampleThe code for this will be −const str = "abbcccddddeeeeedcba" const maxPower = (str = '') => { let power = 1 const sz = str.length - 1 for(let i = 0; i < sz; ++i) { ... Read More

483 Views
We are required to write a JavaScript function that takes in an array of arrays. Each subarray will contain exactly two items, representing the x and y coordinates respectively.Our function should check whether or not the coordinates specified by these subarrays form a straight line.For example −[[4, 5], [5, 6]] should return true.The array is guaranteed to contain at least two subarrays.ExampleThe code for this will be −const coordinates = [ [4, 5], [5, 6] ]; const checkStraightLine = (coordinates = []) => { if(coordinates.length === 0) return false; let x1 = coordinates[0][0]; let y1 = coordinates[0][1]; let slope1 = null; for(let i=1;i

736 Views
Like the base−2 representation (binary), where we repeatedly divide the base 10 (decimal) numbers by 2, in the base 7 system we will repeatedly divide the number by 7 to find the binary representation.We are required to write a JavaScript function that takes in any number and finds its base 7 representation.For example −base7(100) = 202ExampleThe code for this will be −const num = 100; const base7 = (num = 0) => { let sign = num < 0 && '−' || ''; num = num * (sign + 1); let result = ''; while (num) { result = num % 7 + result; num = num / 7 ^ 0; }; return sign + result || "0"; }; console.log(base7(num));OutputAnd the output in the console will be −202

228 Views
We are required to write a JavaScript program that adds two numbers represented as strings, without using any conversion library or built-in methods. For example, If the input number strings are '11' and '23', the output should be '34'. In JavaScript, a number is considered a string-represented number when the number is enclosed in single quotes ('number') or double quotes ("number"). For example: '123' or "456". If you use the typeof operator on such values, it will return the type as 'string'. Here are a few input and output scenarios that provide a better understanding of the given problem: Scenario ... Read More

261 Views
Suppose, we have an array of objects like this −const arr = [ { col1: ["a", "b"], col2: ["c", "d"] }, { col1: ["e", "f"], col2: ["g", "h"] } ];We are required to write a JavaScript function that takes in one such array and returns the following output.const output = [ { col1: "b", col2: "d" }, { col1: "f", col2: "h" } ];Basically, we want to convert ... Read More

812 Views
We are required to write a JavaScript function that takes in two strings as arguments. The function should then check the two strings for common characters and prepare a new string of those characters.Lastly, the function should return that string.The code for this will be −Exampleconst str1 = "IloveLinux"; const str2 = "weloveNodejs"; const findCommon = (str1 = '', str2 = '') => { const common = Object.create(null); let i, j, part; for (i = 0; i < str1.length - 1; i++) { for (j = i + 1; j

13K+ Views
Suppose we have two arrays of objects like these −const arr1 = [{id:'1', name:'A'}, {id:'2', name:'B'}, {id:'3', name:'C'}, {id:'4', name:'D'}]; const arr2 = [{id:'1', name:'A', state:'healthy'}, {id:'3', name:'C', state:'healthy'}];We are required to write a JavaScript function that takes in two such arrays. Our function should return a new filtered version of the first array (arr1 in this case) that contains only those objects with a name property that are not contained in the second array (arr2 in this case) with the same name property.Therefore, the output, in this case, should look like −const output = [{id:'2', name:'B'}, {id:'4', name:'D'}];ExampleThe code ... Read More

797 Views
Sorting an object in ascending order by the value of a key is a common task in JavaScript. Objects are data structures, which are a collection of key-value pairs. Since objects in JavaScript are unordered collections, sorting them directly is not possible. This article will guide you on how to sort an object in ascending order by the value of a key in JavaScript. Understanding the Concept Suppose we have the following object: const obj = { "sub1": 56, "sub2": 67, "sub3": 98, "sub4": 54, ... Read More

1K+ Views
Suppose, we have an array of objects like this −const arr = [{ name : 'Client 1', total: 900, value: 12000 }, { name : 'Client 2', total: 10, value: 800 }, { name : 'Client 3', total: 5, value : 0 }];We are required to write a JavaScript function that takes in one such array and extracts a separate array for each object property.Therefore, one array for the name property of each object, one for total and one for value. If there existed more properties, we would have separated more ... Read More