- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Monica Mona has Published 85 Articles
Monica Mona
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
Monica Mona
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
Monica Mona
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
Monica Mona
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
Monica Mona
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
Monica Mona
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
Monica Mona
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
Monica Mona
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
Monica Mona
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
To Continue Learning Please Login
Login with Google