A JSON (JavaScript object notation) Object is always surrounded by the curly braces {}. The values must be a valid JSON data type, and the keys must be strings. JSON supports the following data types: number, string, object, Boolean, array, and null. There has to be a colon (":") separating the keys and values. A comma separates each key and value pair. Following is the syntax of JSON Object − JSONObject = {} Following is the basic declaration of JSON Object in JavaScript − JSONObject = { "name" : "Suriya", ... Read More
We are required to write a JavaScript program that takes in a number and finds the product of all of its digits. Input output scenarios Assume there is a number digit assigned to a variable and task is to find the product of the number. Input = 12345; Output = 120 Let’s look into another scenario, where we convert the string number digit into int value and multiply them. Input = "12345"; Output = 120 Math.floor() Math.floor() function in JavaScript returns the largest integer which is less than equal to a given number. In simple ... Read More
An Array in JavaScript is datatype which is used to store homogeneous elements. These elements are stored at contiguous memory locations. We can access each data element in the array with the help of index numbers. The index numbers will start from 0. Syntax Following is the syntax of creating a JavaScript array − const array_name = [item1, item2, ...]; The following is the simple declaration of array in JavaScript. Const Body = ['Eyes', 'Nose', 'Lips', 'Ears']; Finding the mid element of an array We are required to write a JavaScript program that finds the middlemost ... Read More
An Array is known as collection of similar data elements which are stored at contiguous memory locations. Array is such a simple data structure where we can access each data element in the array with the help index numbers, which starts from 0. The following is the basic declaration of array in JavaScript − const mobiles = ["SAMSUNG", "ONEPLUS", "APPLE"]; Sum of two consecutive elements of an array We are required to write a JavaScript function that takes in an array of Numbers and returns a new array with elements as sum of two consecutive elements from ... Read More
The YouTube platform is booming day by day, a new content creator has a tremendous opportunity to build a successful YouTube channel from scratch. Before you dive into the ocean of video content, there are some things that you need to think about to maximize your chances of success. The purpose of Starting a Channel One of the most important YouTube tips for beginners is to know the purpose of starting the channel. It’s a passion, promoting the business or trying to make a YouTube channel as a business. Defining a purpose will help to make content. The purpose is ... Read More
YouTube Premium is a monthly subscription service which promise to improve viewing experience on the internet’s largest video platform. YouTube Premium is the paid subscription service with very nominal charges offering its users money saver plans. Premium offers ad-free viewing of every video, offline playback of audio and video, and exclusive content made by famous YouTubers. Today, video ad revenues are falling day by day, which has led creators to put more ads in their videos. So, YouTube Premium will make you watch uninterrupted while still supporting those who make them. The Benefits of Premium Subscribing to ... Read More
Given an array, and generate the random permutation of array elements. It is similar like shuffling a deck of cards or randomize an array and every outcome after shuffling of array elements should likely and equally. Input output scenarios Consider an array having some elements present in it and assume we have performed fisher yates shuffle on that array. The output array will be randomly shuffled and shuffles for every time we execute. All the permutations are equally and likely. Input = [2, 4, 6, 8, 10] Output = 4, 10, 6, 2, 8 // first iteration ... Read More
Insertion Sort The Insertion Sort is a sorting algorithm that works very similar to the way we sort the playing cards when we play. The arrangement of elements in a sorted manner. In this algorithm, the array will be divide virtually into two parts which are sorted and unsorted parts. The values present in unsorted part will be pick and placed at the correct position where it satisfies the sorting order. The Insertion sort is simple algorithm having simple implementation. Generally, this algorithm is efficient for smart data values. This is suitable for data sets which are already partly ... Read More
Merge Sort The Merge Sort algorithm, where we can sort the elements in a particular order. This algorithm is also considered as an example of divide and conquer strategy. In merge sort algorithm, firstly the array will be divided into two parts and combined a particular sorted manner. The array will be divided into half until it cannot be divided. This means that if the array is completely divided and cannot be further divided, the dividing will be stopped. We divide the arrays into halves and implement merge sort on each of the halves. This algorithm is a ... Read More
A string is an order of one or more characters that contain numbers, letters, symbols, or special characters. In JavaScript strings are immutable. i.e., once you create a string you cannot change its value. For example, consider the following snippet here we have created a string variable and assigned a value (Tutorialspoint) to it. In the next statement, we are trying to change the contents of the string at the first index. Then we are displaying the contents of the string. let x = 'Tutorialspoint'; x[0] = 't'; console.log(x); //Tutorialspoint. On executing this code ... Read More