Articles on Trending Technologies

Technical articles with clear explanations and examples

Replacing digits to form binary using JavaScript

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 581 Views

ProblemWe are required to write a JavaScript function that takes in a string of digits. Our function should replace any digit below 5 with '0' and any digit 5 and above with '1' and return the resulting string.ExampleFollowing is the code −const str = '262355677834342'; const convert = (str = '') => {    let res = '';    for(let i = 0; i < str.length; i++){       const el = +str[i];       if(el < 5){          res += 0;       }else{          res += 1;       };    };    return res; }; console.log(convert(str));Output010011111100000

Read More

Merging and rectifying arrays in JavaScript

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 175 Views

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 should delete the excess duplicates so that only one copy of each element is present in the merged array.The order here is not so important but the frequency of elements (which should be 1 for each element) is important.For example, if the input to the function is −onst arr1 = ...

Read More

Read and Write Input in Dart Programming

Mukul Latiyan
Mukul Latiyan
Updated on 11-Mar-2026 2K+ Views

Dart provides us with a standard library named 'io' which contains different classes and in turn, these classes contains different methods that we can use to read or write input from the terminal.We import the library in our program by making use of the import command.ExampleConsider the example shown below −Import 'dart:io';Writing something to the terminalWe can write something to the terminal by making use of the standard out class (stdout) that is available to us in the 'dart:io' library.ExampleConsider the example shown below −import 'dart:io'; void main(List arguments) {    stdout.write('What is your name?\r'); }OutputWhat is your name?Note − ...

Read More

Returning the nth even number using JavaScript

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 632 Views

ProblemWe are required to write a JavaScript function that takes in a number n. And our function should simply return the nth even number in natural numbers.ExampleFollowing is the code −const num = 67765; const nthEven = (num = 1) => {    const next = num * 2;    const res = next - 2;    return res; }; console.log(nthEven(num));Output135528

Read More

Find number of times every day occurs in a Year in Python

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 684 Views

When it is required to find the number of times every day of the week occurs in a year, a list is defined, and it is iterated over, and is count is incremented respectively.Below is a demonstration of the same −Exampleimport math def num_of_occurrence( n, firstday):    my_days = [ "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ]    my_count= [4 for i in range(0, 7)]    my_position = -1    for i in range(0, 7):       if (first_day == my_days[i]):          my_position = i          break   ...

Read More

Returning array of natural numbers between a range in JavaScript

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 217 Views

ProblemWe are required to write a JavaScript function that takes in an array of two numbers [a, b] (a {    if(lower > upper){       return [];    };    const res = [];    for(let i = lower; i

Read More

Filtering out numerals from string in JavaScript

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 204 Views

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, if the input to the function is −const str = 'revd1fdfdfs2v34fd5gfgfd6gffg7ds';Then the output should be −const output = '1234567';ExampleFollowing is the code −const str = 'revd1fdfdfs2v34fd5gfgfd6gffg7ds'; const pickNumbers = (str = '') => {    let res = '';    for(let i = 0; i < str.length; i++){     ...

Read More

Return statement in Dart Programming

Mukul Latiyan
Mukul Latiyan
Updated on 11-Mar-2026 1K+ Views

There are certain cases where we want to return a value from a given function so that we can use it later. These return values make use of a return keyword which in turn allows a function to return values.It should be noted that the return statement is optional, if not specified the function returns null.Also, only one return statement is allowed in a function.Syntaxreturn ;Syntax of a Dart function with a return value −returnType funcName(){    // statement(s)    return value; }In the above syntax, the funcName is replaced with the name of our function. The returnType represents the type of data/expression ...

Read More

DNA to RNA conversion using JavaScript

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 936 Views

DNA And RNA RelationDeoxyribonucleic acid, DNA is the primary information storage molecule in biological systems. It is composed of four nucleic acid bases Guanine ('G'), Cytosine ('C'), Adenine ('A'), and Thymine ('T').Ribonucleic acid, RNA, is the primary messenger molecule in cells. RNA differs slightly from DNA its chemical structure and contains no Thymine. In RNA Thymine is replaced by another nucleic acid Uracil ('U').ProblemWe are required to write a JavaScript function which translates a given DNA string into RNA.ExampleFollowing is the code −const DNA = 'GCAT'; const DNAtoRNA = (DNA) => {    let res = '';    for(let i ...

Read More

Merging nested arrays to form 1-d array in JavaScript

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 370 Views

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 to the function is −const arr1 = [    1, [       2, [          4, 5, [             6          ]       ]    ] ]; const arr2 = [    11, 12, [ ...

Read More
Showing 1321–1330 of 61,248 articles
« Prev 1 131 132 133 134 135 6125 Next »
Advertisements