Tuesday , October 4 2022
Breaking News

# javascript

## How to swap two numbers without using a temporary variable?

Solution – 1 – Using Arithmetic Operators function swapNumb(a, b){ console.log('Before swap Output: ','a: ', a, 'b: ', b); b = b -a; a = a+ b; b = a-b; console.log('After swap Output: ','a: ', a, 'b: ', b); } swapNumb(2, 3); Solution – 2 – Using Bitwise XOR function …

## How to Create and get nth Fibonacci series number?

What is the Fibonacci series? Fibonacci series is the series of numbers that are calculated by adding the values of the previous two numbers in the sequence. The first two numbers of the sequence are zero and one. It is also known as the golden ratio. We can represent the …

## Simple JavaScript code in promises.

function promiseExample(){ const promise = new Promise((resolve, reject) =>{ resolve('successfully!'); }) .then((resolve) => console.log(resolve)) .catch((reject) => console.log(reject)); return promise; } promiseExample() I have a create simple code example for promises. you can easily check. how to resolve is working? and how to reject is working?

## You are given a two-digit integer n. Return the sum of its digits.

You are given a two-digit integer n. Return the sum of its digits. Example For n = 29, the output should be solution(n) = 11. Input/Output [execution time limit] 4 seconds (js) [input] integer n A positive two-digit integer. Guaranteed constraints: 10 ≤ n ≤ 99. [output] integer The sum …

## Given an array of integers a, your task is to count the number of pairs i and j (where 0 ≤ i < j < a.length), such that a[i] and a[j] are digit anagrams.

Given an array of integers a, your task is to count the number of pairs i and j (where 0 ≤ i < j < a.length), such that a[i] and a[j] are digit anagrams. Two integers are considered to be digit anagrams if they contain the same digits. In other …