Merging nested arrays to form 1-d array in JavaScript

AmitDiwan
Published on 21-Apr-2021 15:36:51
ProblemWe are required to write a JavaScript function that takes in two nested arrays, arr1 and arr2, as the first and the second argument.Our function should create and return a third array that contains all the elements of arr1 and arr2 but flattened to single dimensionFor example, if the input ... Read More

Filtering out numerals from string in JavaScript

AmitDiwan
Published on 21-Apr-2021 15:28:13
ProblemWe are required to write a JavaScript function that takes in a string, str, which contains a combination of alphabets, special characters and numbers.Our function should return a new string based on the input string that contains only the numbers present in the string str, maintaining their relative order.For example, ... Read More

Decreasing order sort of alphabets in JavaScript

AmitDiwan
Published on 21-Apr-2021 15:24:37
ProblemWe are required to write a JavaScript function that takes in a lowercase English alphabets string, str, as the first and the only argumentOur function should create and return a new string based on the input string which contains characters sorted according to the reverse English alphabets.For example, if the ... Read More

Merging and rectifying arrays in JavaScript

AmitDiwan
Published on 21-Apr-2021 15:19:19
ProblemWe are required to write a JavaScript function that takes in two arrays of numbers, arr1 and arr2, as the first and the second arguments.Our function should merge the elements of both these arrays into a new array and if upon merging or before merging there exists any duplicates, we ... Read More

Checking for special numbers in JavaScript

Ranjit Kumar
Published on 21-Apr-2021 15:09:20
ProblemWe are required to write a JavaScript function that takes in a number, num, as the first and the only argument.Our function should return true if the sum of the digits of the number num is a palindrome number, false otherwise.For example, if the input to the function is −const ... Read More

Accumulating array elements to form new array in JavaScript

AmitDiwan
Published on 21-Apr-2021 14:00:36
ProblemWe are required to write a JavaScript function that takes in an array of numbers, arr, as the first argument and a number, num, (num <= length of array) as the second argumentOur function should add up each contiguous subarray of length num of the array arr to form corresponding ... Read More

Common element with least index sum in JavaScript

AmitDiwan
Published on 21-Apr-2021 13:54:06
ProblemWe are required to write a JavaScript function that takes in two arrays of literals, arr1 and arr2, as the first and the second argument.Our function should find out the common element in arr1 and arr2 with the least list index sum. If there is a choice tie between answers, ... Read More

How to bind a key to a button in Tkinter?

Dev Prakash Sharma
Published on 21-Apr-2021 11:16:43
Tkinter provides a way to bind the widget to perform certain operations. These operations are defined in a function that can be called by a particular widget. The bind(<button>, function()) method is used to bind the keyboard key to handle such operations. We can also bind a particular key to ... Read More

How to add an image in Tkinter?

Dev Prakash Sharma
Published on 21-Apr-2021 11:15:53
Images are very useful objects in any application. We can process Images in a Tkinter application using the Pillow or PIL package in Python. There are several built-in functions such as loading an image, extracting an image, configuring the image pane, etc.ExampleIn this example, we will add by asking the ... Read More

How do you check if a widget has a focus in Tkinter?

Dev Prakash Sharma
Published on 21-Apr-2021 11:14:34
Let us assume that we want to check if a particular widget has a focused set or not. The only way to check the widget focus is to use the utility method focus_get(). It returns the object containing the widget’s information which is currently focused on, during the program’s execution. ... Read More
Advertisements