Manikanth Mani has Published 48 Articles

How to return a random number between 1 and 200 with JavaScript?

Manikanth Mani

Manikanth Mani

Updated on 24-Nov-2023 00:44:49

1K+ Views

To return a random number between 1 and 200, use the JavaScript's Math.random() and Math.floor() method. Example You can try to run the following code to return a random number in JavaScript.                    document.write(Math.floor(Math.random() * 200) + 1);          

What is the usage of onfocusin event in JavaScript?

Manikanth Mani

Manikanth Mani

Updated on 23-Jun-2020 09:06:49

105 Views

The onfocusin event triggers when an element is to get focus. You can try to run the following code to learn how to implement onfocusin event in JavaScript −Example           Write below:                      function newFunc(x) {             x.style.background = "blue";          }          

How to return a string value version of the current number?

Manikanth Mani

Manikanth Mani

Updated on 23-Jun-2020 08:42:43

140 Views

The toLocaleString() method returns a string value version of the current number in a format that may vary according to a browser's local settings.ExampleYou can try to run the following code to return a string value version −           JavaScript toLocaleString() Method                        var num = new Number(150.1234);          document.write( num.toLocaleString());          

How to apply a function simultaneously against two values of the array from left-to-right?

Manikanth Mani

Manikanth Mani

Updated on 23-Jun-2020 08:28:25

117 Views

Use the reduce() method in JavaScript to apply a function simultaneously against two values of the array from left-to-right as to reduce it to a single value.The following are the parameters −callback − Function to execute on each value in the array.initialValue − Object to use as the first argument to the ... Read More

How to convert a date to a string using current locale's conventions?

Manikanth Mani

Manikanth Mani

Updated on 23-Jun-2020 07:54:51

100 Views

JavaScript date toLocaleString() method converts a date to a string, using the operating system's local conventions.The toLocaleString method relies on the underlying operating system in formatting dates. It converts the date to a string using the formatting convention of the operating system where the script is running. For example, in ... Read More

How can I move an existing MySQL event to another database?

Manikanth Mani

Manikanth Mani

Updated on 22-Jun-2020 12:51:23

157 Views

It can be done with the help of ALTER EVENT statement too. We need to use the combination of database name and event name along with the RENAME keyword. To illustrate it we are having the following example in which we are moving the event named ‘hello_renamed’ from ‘query’ database ... Read More

How can we check the list of all triggers in a database?

Manikanth Mani

Manikanth Mani

Updated on 22-Jun-2020 11:52:21

136 Views

With the help of the SHOW TRIGGERS statement, we can list all the triggers in a particular database. It can be illustrated with the help of the following example −Examplemysql> Show Triggers\G *************************** 1. row ***************************   Trigger: trigger_before_delete_sample     Event: DELETE     Table: sample Statement: BEGIN ... Read More

How can REPLACE() be used with UPDATE clause to make permanent changes to a table?

Manikanth Mani

Manikanth Mani

Updated on 22-Jun-2020 07:01:25

134 Views

As we know that REPLACE () function is used to replace the occurrences of a substring with another substring within a string. We can also use the REPLACE function with the UPDATE statement to update the table. Following example will demonstrate it −Examplemysql> Update Student set Father_Name = REPLACE(Father_Name, 'Mr.', ... Read More

In function INSERT(str, Pos, len, newstr), what would be the result if ‘Pos’ is not within the length of the string?

Manikanth Mani

Manikanth Mani

Updated on 22-Jun-2020 06:06:02

101 Views

MySQL INSERT() function performs no insertion if the position of insertion is not within the length of the string. There are certain cases like we pass a negative or 0(zero) value or the value goes beyond the value of a total number of characters in an original string by 2 ... Read More

How can we use MySQL SUM() function to calculate the sum of only dissimilar values of the column?

Manikanth Mani

Manikanth Mani

Updated on 22-Jun-2020 05:12:02

71 Views

For calculating the sum of only dissimilar values of the column we can use ‘DISTINCT’ keyword along with the name of the column. To understand SUM() function for dissimilar values, consider an ‘employee_tbl’ table, which is having the following records −mysql> SELECT * FROM employee_tbl; +------+------+------------+--------------------+ | id   | ... Read More

Advertisements