
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 10483 Articles for Web Development

143 Views
We are required to write a JavaScript function that takes in two strings and find the number of corresponding dissimilarities in the stringsThe corresponding elements will be dissimilar if they are not equal. Let’s say the following are our two string −const str1 = 'Hello world!!!'; const str2 = 'Hellp world111';ExampleFollowing is the code −const str1 = 'Hello world!!!'; const str2 = 'Hellp world111'; const dissimilarity = (str1 = '', str2 = '') => { let count = 0; for(let i = 0; i < str1.length; i++){ if(str1[i] === str2[i]){ continue; ... Read More

522 Views
We are required to write a JavaScript function that takes in a string and reverses the words in the string that have an odd number of characters in them.Any substring in the string qualifies to be a word, if either it is encapsulated by two spaces on either ends or present at the end or beginning and followed or preceded by a space.Let’s say the following is our string −const str = 'hello beautiful people';The odd length words are −hello beautifulExampleLet us write the code for this function.const str = 'hello beautiful people'; const idOdd = str => str.length % ... Read More

230 Views
We are required to write a JavaScript function that takes in a sentence string and a character and the function should reverse all the words in the string starting with that particular character.For example: If the string is −const str = 'hello world, how are you';Starting with a particular character ‘h’ −Then the output string should be −const output = 'olleh world, woh are you';That means, we have reversed the words starting with “h” i.e. Hello and How.ExampleFollowing is the code −const str = 'hello world, how are you'; const reverseStartingWith = (str, char) => { const strArr = ... Read More

246 Views
We are required to write a JavaScript function that takes in a string that contains only '+' or '-' and we have to return either '+' or '-' based on the whole neutralisation result of the string.Like '++' results to '+' and '--' also results to '+' while '-+' or '+-' results to '-'.Following is our string −const str = '+++-+-++---+-+--+-';ExampleFollowing is the code −const str = '+++-+-++---+-+--+-'; const netResult = (str = '') => { const strArr = str.split(''); return strArr.reduce((acc, val) => { if(acc === val){ return '+'; ... Read More

254 Views
A number is Oddish if the sum of all of its digits is odd, and a number is Evenish if the sum of all of its digits is even.We are required to write a function that determines whether a number is Oddish or Evenish. We should return true of Oddish values and false for evenishExampleFollowing is the code −const num = 434667; const isOddish = (num, sum = 0) => { if(num){ return isOddish(Math.floor(num / 10), sum + (num % 10)); }; return sum % 2 === 1; }; console.log(isOddish(num));OutputFollowing is the output in the console −false

272 Views
HOCHOC or Higher Order Functions in JavaScript are a special type of functions that receives another function as argument or have a function set as their return value or do both. HOC along with closures is a very powerful tool in JavaScript.We are required to write a JavaScript Higher Order Function that can be used to obtain the product of two numbers.ExampleFollowing is the code −const num1 = 24; const num2 = 5; const productHOC = num1 => { return product = num2 => { return num1 * num2; }; }; console.log(productHOC(num1)(num2));OutputFollowing is the output in the console −120

144 Views
We are required to write a JavaScript function that takes in a number as a string and returns a new number string with all the leading and trailing 0s removedFor example: If the input is −const strNum = '054954000'Then the output should be −const output = '54954'ExampleFollowing is the code −const strNum = '054954000'; const removeZero = (str = '') => { const res = ''; let startLen = 0, endLen = str.length-1; while(str[startLen] === '0'){ startLen++; }; while(str[endLen] === '0'){ endLen--; }; return str.substring(startLen, endLen+1); }; console.log(removeZero(strNum));OutputFollowing is the output in the console −54954

542 Views
An array is a special array if −--All the elements at odd indices are odd. --All the elements at even indices are even.We are required to write a JavaScript function that takes in an array and checks if its a special array or not.ExampleFollowing is the code −const arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; const isSpecial = (arr = []) => { for(let i = 0; i < arr.length; i++){ if(arr[i] % 2 === i % 2){ continue; }; return false; }; return true; }; console.log(isSpecial(arr));OutputFollowing is the output in the console −true

314 Views
We are required to write a JavaScript function that takes in a string with uppercase and lowercase letters. The function should return a string with all the uppercase letters moved to front of the string.For example: If the input string is −const str = 'heLLO woRlD';Then the output should be −const output = 'LLORDhe wol';ExampleFollowing is the code −const str = 'heLLO woRlD'; const moveCapitalToFront = (str = '') => { let capitalIndex = 0; const newStrArr = []; for(let i = 0; i < str.length; i++){ if(str[i] !== str[i].toLowerCase()){ ... Read More

542 Views
We are required to write a JavaScript function that takes in any number of JavaScript arrays and returns one single array with all the values from input arrays concatenated into it.For example − If the input arrays are −[1, 5], [44, 67, 3], [2, 5], [7], [4], [3, 7], [6]Then the output should be −const output = [1, 5, 44, 67, 3, 2, 5, 7, 4, 3, 7, 6];ExampleFollowing is the code −const a = [1, 5], b = [44, 67, 3], c = [2, 5], d = [7], e = [4], f = [3, 7], g = [6]; const concatArrays = (...arr) => { const res = arr.reduce((acc, val) => { return acc.concat(...val); }, []); return res; }; console.log(concatArrays(a, b, c, d, e, f, g));OutputFollowing is the output in the console −[ 1, 5, 44, 67, 3, 2, 5, 7, 4, 3, 7, 6 ]