AmitDiwan has Published 10744 Articles

Number of vowels within an array in JavaScript

AmitDiwan

AmitDiwan

Updated on 20-Nov-2020 09:40:22

741 Views

We are required to write a JavaScript function that takes in an array of strings, (they may be a single character or greater than that). Our function should simply count all the vowels contained in the array.ExampleLet us write the code −const arr = ['Amy', 'Dolly', 'Jason', 'Madison', 'Patricia']; const ... Read More

Array filtering using first string letter in JavaScript

AmitDiwan

AmitDiwan

Updated on 20-Nov-2020 09:39:08

2K+ Views

Suppose we have an array that contains name of some people like this:const arr = ['Amy', 'Dolly', 'Jason', 'Madison', 'Patricia'];We are required to write a JavaScript function that takes in one such string as the first argument, and two lowercase alphabet characters as second and third argument. Then, our function ... Read More

Algorithm to sum ranges that lie within another separate range in JavaScript

AmitDiwan

AmitDiwan

Updated on 20-Nov-2020 09:38:04

126 Views

We have two sets of ranges; one is a single range of any length (R1) and the other is a set of ranges (R2) some or parts of which may or may not lie within the single range (R1).We need to calculate the sum of the ranges in (R2) - ... Read More

Splitting an array into groups in JavaScript

AmitDiwan

AmitDiwan

Updated on 20-Nov-2020 09:37:38

2K+ Views

We are required to write a JavaScript function that takes in an array of literals and a number and splits the array (first argument) into groups each of length n (second argument) and returns the two-dimensional array thus formed.If the array and number is −const arr = ['a', 'b', 'c', ... Read More

How does spring boot connect localhost MySQL

AmitDiwan

AmitDiwan

Updated on 20-Nov-2020 07:33:57

2K+ Views

For this, use application.properties −spring.datasource.username=yourMySQLUserName spring.datasource.password=yourMySQLPassword spring.datasource.url=jdbc:mysql://localhost:3306/yoruDatabaseName spring.datasource.driver-class-name=com.mysql.cj.jdbc.DriverTo understand the above syntax, let us create a table −mysql> create table demo71 −> ( −> id int, −> name varchar(20) −> ); Query OK, 0 rows affected (3.81 sec)Insert some records into the table with the help of insert command −mysql> ... Read More

What is the difference Between AND, OR operator in MySQL while Retrieving the Rows?

AmitDiwan

AmitDiwan

Updated on 20-Nov-2020 07:31:21

2K+ Views

The difference between AND, OR is that AND evaluates both conditions must be true for the overall condition to be true. The OR evaluates one condition must be true for the overall condition to be true.Let us create a table −mysql> create table demo70 −> ( −> id int not ... Read More

Update all varchar column rows to display values before slash in MySQL?

AmitDiwan

AmitDiwan

Updated on 20-Nov-2020 07:29:12

226 Views

For this, use UPDATE command along with SUBSTRING_INDEX(). Let us first create a table −mysql> create table demo69 −> ( −> name varchar(40) −> ); Query OK, 0 rows affected (5.04 sec)Insert some records into the table with the help of insert command −mysql> insert into demo69 values('John/Smith'); Query OK, ... Read More

How to combine few row records in MySQL?

AmitDiwan

AmitDiwan

Updated on 20-Nov-2020 07:28:10

122 Views

For this, use CASE WHEN concept. Let us first create a table −mysql> create table demo68 −> ( −> id int not null auto_increment primary key, −> company_name varchar(50), −> employee_name varchar(50), −> country_name varchar(50) −> ); Query OK, 0 rows affected (1.86 sec)Insert some records into the table with ... Read More

MySQL limit in a range fail to display first 3 row?

AmitDiwan

AmitDiwan

Updated on 20-Nov-2020 07:25:50

127 Views

Following is the syntax to display only the first 3 rows with LIMIT set in a range −select *from yourTableName limit yourStartIndex, yourEndIndex;Let us first create a table −mysql> create table demo67 −> ( −> id int, −> user_name varchar(40), −> user_country_name varchar(20) −> ); Query OK, 0 rows affected ... Read More

MySQL database field type for search query?

AmitDiwan

AmitDiwan

Updated on 20-Nov-2020 07:21:08

180 Views

Following is the syntax −select *from yourTableName where REGEXP_INSTR(yourColumnName, yourSearchValue);To understand the above syntax, let us first create a table −mysql> create table demo64 −> ( −> id int not null auto_increment primary key, −> name varchar(40) −> ); Query OK, 0 rows affected (3.06 sec)Insert some records into the ... Read More

Advertisements