Monica Mona has Published 85 Articles

Factorial of a large number

Monica Mona

Monica Mona

Updated on 17-Jun-2020 09:19:15

1K+ Views

In computers, variables are stored in memory locations. But the size of the memory location is fixed, so when we try to find the factorial of some greater value like 15! or 20! the factorial value exceeds the memory range and returns wrong results.For calculation of large numbers, we have ... Read More

Find GCD of two numbers

Monica Mona

Monica Mona

Updated on 17-Jun-2020 08:18:25

1K+ Views

In mathematics, Greatest Common Divisor (GCD) is the largest possible integer, that divides both of the integers. The condition is that the numbers must be non-zero.We will follow the Euclidean Algorithm to find the GCD of two numbers.Input and OutputInput: Two numbers 51 and 34 Output: The GCD is: 17AlgorithmfindGCD(a, ... Read More

What are variadic functions in Java?

Monica Mona

Monica Mona

Updated on 16-Jun-2020 06:19:30

734 Views

Methods which uses variable arguments (varargs, arguments with three dots) are known as variadic functions.ExampleLive Demopublic class Sample {     void demoMethod(String... args) {       for (String arg: args) {          System.out.println(arg);       }     }    public static void ... Read More

How to use telephone input type in HTML?

Monica Mona

Monica Mona

Updated on 15-Jun-2020 11:27:18

431 Views

The telephone input type is used in HTML using the . Using this, allow the users to add telephone number.Note − The input type tel is only supported in Safari.ExampleYou can try to run the following code to learn how to use input type tel to allow user input in ... Read More

Creating Dictionary using Javascript

Monica Mona

Monica Mona

Updated on 15-Jun-2020 10:52:03

1K+ Views

Let's create a MyMap class so that it doesn't hide the actual Map class in JS. We'll create a container object that'll keep track of all our values that we add to the map. We'll also create a display function that prints the map for us. Exampleclass MyMap {    constructor() ... Read More

Add elements to a Dictionary in Javascript

Monica Mona

Monica Mona

Updated on 15-Jun-2020 10:49:38

8K+ Views

Now we'll create the put method that'll allow us to put key-value pairs on the dictionary. Now using this we'll implement the put method.Note that JS has objects that act quite like dictionaries. We can just set the container's key property to value. Exampleput(key, value) {    this.container[key] = value; }You ... Read More

Search Element in a Dictionary using Javascript

Monica Mona

Monica Mona

Updated on 15-Jun-2020 10:43:22

2K+ Views

We'll implement the get method that searches a given key in the dictionary. Exampleget(key) {    if(this.hasKey(key)) {       return this.container[key];    }    return undefined; }Again, JS objects are very much implemented like dictionaries, hence have most of the functionality we can use directly without any more code ... Read More

Clearing a Dictionary using Javascript

Monica Mona

Monica Mona

Updated on 15-Jun-2020 10:37:12

1K+ Views

We'll implement a clear() function that simply clears the contents of the container. For example,  Exampleclear() {    this.container = {} }You can test this using − Exampleconst myMap = new MyMap(); myMap.put("key1", "value1"); myMap.put("key2", "value2");   myMap.display(); myMap.clear(); myMap.display();OutputThis will give the output −{ key1: 'value1', key2: 'value2' }You can ... Read More

Loop through a Dictionary in Javascript

Monica Mona

Monica Mona

Updated on 15-Jun-2020 10:34:46

9K+ Views

Here we'll implement a for each function in our class and accept a callback that we can call on every key-value pair. Let's see how we can implement such a function − ExampleforEach(callback) {    for (let prop in this.container) {       // Call the callback as: callback(key, value) ... Read More

Show dangerous action on a table row with Bootstrap

Monica Mona

Monica Mona

Updated on 12-Jun-2020 19:09:23

47 Views

Use the .danger class in Bootstrap to show dangerous action for a table rowExampleLive Demo           Bootstrap Example                                          Rank of Cricketers          The following are the rank of cricketers:                                                         Cricketer                   Rank                                                                           Virat                   1                                                   David                   2                                                   Rohit                   3                                                   Kenn                   4                                                   Steve                   5                                                

Advertisements