Found 10710 Articles for Web Development

Placing integers at correct index in JavaScript

AmitDiwan
Updated on 23-Apr-2021 07:43:05

52 Views

ProblemWe are required to write a JavaScript function that takes in a string, str, which consists of only ‘[‘ or ‘]’. Our function is supposed to add the minimum number of square brackets ( '[' or ']', and in any positions ) so that the resulting bracket combination string is valid. And lastly, we should return the smallest number of brackets added.For example, if the input to the function isInputconst str = '[]]';Outputconst output = 1;Output ExplanationBecause, if we add ‘[‘ to the starting, the string will be balanced.Exampleconst findAdditions = (str = '') => {    let left = 0 ... Read More

Binary subarrays with desired sum in JavaScript

AmitDiwan
Updated on 23-Apr-2021 07:26:00

59 Views

ProblemWe are required to write a JavaScript function that takes in a binary array, arr, as the first argument, and a number, target, as the second argument.Our function is supposed to count the number of subarrays that exists in the array arr, the sum of whose elements is equal to count. We should finally return this count.For example, if the input to the function isInputconst arr = [1, 0, 1, 0, 1]; const target = 2;Outputconst output = 4;Output ExplanationBecause the desired subarrays are:[1, 0, 1][1, 0, 1, 0] [0, 1, 0, 1] [1, 0, 1]Example Live Democonst arr = [1, ... Read More

Finding minimum flips in a binary string using JavaScript

AmitDiwan
Updated on 23-Apr-2021 07:35:10

123 Views

Monotonically Increasing String:A string of '0's and '1's is monotonically increasing if it consists of some number of '0's (possibly 0), followed by some number of '1's (also possibly 0.)ProblemWe are required to write a JavaScript function that takes in a binary string, str, as the first and the only argument.We can flip any ‘0’ to ‘1’ or any ‘1’ to ‘0’ present in the string. Our function should return the minimum number of flips to make S monotonically increasing.For example, if the input to the function isInputconst str = '00110';Outputconst output = 1;Output ExplanationBecause if we flip the last ... Read More

Difference Between URL and Domain Name

Kiran Kumar Panigrahi
Updated on 21-Dec-2022 11:21:57

5K+ Views

Both URL and Domain Name are two very common terms related to the Internet or web address. Sometimes, these are used interchangeably, but they are entirely different from each other. URL (Uniform Resource Locator) is the complete address of a web resource such as a webpage, whereas the Domain Name is the part of a URL that represents an IP address in a human friendly form. Read this article to find out more about URL and Domain Name and how they are different from each other. What is URL? A URL is a complete Internet address of a web ... Read More

Difference Between Cache and Cookies

AmitDiwan
Updated on 23-Apr-2021 06:48:33

1K+ Views

In this post, we will understand the difference between cache and cookies −CacheIt helps store the content of the website which is used frequently.The content of the website is stored in the browser.It expires manually.It consumes more space.Different types of cache are: Browser cache and proxy cache.It stores contents like HTML pages, images, JavaScript, CSS.It doesn’t send a response with a request.CookiesIt helps store the user’s choice.The contents of the cookie are stored in both the server and browser.It expires automatically.It consumes less space.Different types of cookies are: Transient cookies and persistent cookies.A cookie stores the contents such as browsing ... Read More

Difference Between WordPress.com and WordPress.org

AmitDiwan
Updated on 23-Apr-2021 06:46:40

56 Views

In this post, we will understand the difference between wordpress.com and wordpress.org −Wordpress.orgIt is also known as the real WordPress.It is open source, and can be used by anyone.A domain name and a web hosting service is required to use this.It is also referred to as self-hosted WordPress.User has full control of the website.WordPress plugins that are free, or paid can be added to the website.The website and all of its data is owned by the user.Google analytics can be used to perform customized analytics.Advertisements can be run and revenue can be generated.User has to keep several backups of the ... Read More

Difference Between Website and Portal

Kiran Kumar Panigrahi
Updated on 02-Dec-2022 06:07:29

7K+ Views

Websites and Portals both have a webbased interface. They are correlated terms in the Internet terminology. The basic difference between a website and a portal is that a website is a collection of related webpages, whereas a portal is a gateway to the World Wide Web and is used to access various services of the Internet. In this article, we will discuss the important differences between website and portal. Let's start with a basic introduction of what websites and portals are. What is a Website? A Website is a collection of related webpages and is made to available under one ... Read More

Validating alternating vowels and consonants in JavaScript

AmitDiwan
Updated on 22-Apr-2021 11:57:13

149 Views

ProblemWe are required to write a JavaScript function that takes in a string of English alphabets, str, as the first and the only argument. Our function should return true if and only if the vowels and consonants appear alternatingly in the input string, false otherwise.For example, if the input to the function is −Inputconst str = 'amazon';Outputconst output = true;Output ExplanationBecause the vowels and consonants appear alternatingly in the string ‘amazon’.ExampleFollowing is the code − Live Democonst str = 'amazon'; const appearAlternatingly = (str = '') => {    return str.split('').every((v, i)=>{     if (/[aeiou]/.test(str[0])){       ... Read More

Checking for squared similarly of arrays in JavaScript

AmitDiwan
Updated on 22-Apr-2021 11:49:05

72 Views

ProblemWe are required to write a JavaScript function that takes in two arrays of numbers, arr1 and arr2, as the first and second argument respectively.Our function should return true if and only if every element in arr2 is the square of any element of arr1 irrespective of their order of appearance.For example, if the input to the function is −Inputconst arr1 = [4, 1, 8, 5, 9]; const arr2 = [81, 1, 25, 16, 64];Outputconst output = true;ExampleFollowing is the code − Live Democonst arr1 = [4, 1, 8, 5, 9]; const arr2 = [81, 1, 25, 16, 64]; const isSquared ... Read More

Converting any case to camelCase in JavaScript

AmitDiwan
Updated on 22-Apr-2021 11:46:46

589 Views

ProblemWe are required to write a JavaScript function that takes in a string, str, which can be any case (normal, snake case, pascal case or any other).Our function should convert this string into camelCase string.For example, if the input to the function is −Inputconst str = 'New STRING';Outputconst output = 'newString';ExampleFollowing is the code − Live Democonst str = 'New STRING'; const toCamelCase = (str = '') => {    return str       .replace(/[^a-z0-9]/gi, ' ')       .toLowerCase()       .split(' ')       .map((el, ind) => ind === 0 ? el : el[0].toUpperCase() + el.substring(1, el.length))       .join(''); }; console.log(toCamelCase(str));OutputnewString

Advertisements