Found 9326 Articles for Object Oriented Programming

How to check Minlength and Maxlength validation of a property in C# using Fluent Validation?

Nizamuddin Siddiqui
Updated on 25-Nov-2020 11:46:46

2K+ Views

MaxLength ValidatorEnsures that the length of a particular string property is no longer than the specified value.Only valid on string propertiesString format args:{PropertyName} = The name of the property being validated{MaxLength} = Maximum length{TotalLength} = Number of characters entered{PropertyValue} = The current value of the propertyMinLength ValidatorEnsures that the length of a particular string property is longer than the specified value.Only valid on string properties{PropertyName} = The name of the property being validated{MinLength} = Minimum length{TotalLength} = Number of characters entered{PropertyValue} = The current value of the propertyExamplestatic void Main(string[] args){    List errors = new List();    PersonModel ... Read More

Function for counting frequency of space separated elements in JavaScript

Nikitasha Shrivastava
Updated on 14-Aug-2023 17:55:26

162 Views

In this problem statement, our target is to create a function for counting frequency of space separated elements with the help of Javascript functionalities. Understanding the Problem The given problem is stating that we have given a space separated elements and our task is to count the frequency of space separated items. So we will provide some strings with some space separated items and assign a result array to see the counts of the frequency of such items. For example if we have a string with space separated items like “Car, Bike, Car, Bicycle, Bike”, in this ... Read More

Sorting according to weights of numbers in JavaScript

Nikitasha Shrivastava
Updated on 16-Aug-2023 16:55:33

868 Views

In this problem statement, our target is to sort the given array of numbers according to the weights of numbers with the help of Javascript. At the beginning we will write a function that calculates the weights of the numbers and then sort them with another function. Understanding the Problem We have to sort the provided numbers according to their weights. As a result we will have an array of numbers. A weight of the number is defined as the sum of its own digits. For example: suppose we have an array like [19, 11, 12, 15]. We ... Read More

JavaScript program to convert positive integers to roman numbers

Nikitasha Shrivastava
Updated on 14-Aug-2023 18:30:42

408 Views

In the given problem we have to change the given positive number (the number should be an integer number) into the corresponding roman number and then implement the code using Javascript. Understanding the problem We have to write a Javascript program to generate the roman number representation of given integer numbers in the given problem statement. The code should accept a positive integer as input and will be able to transform the integer into its equivalent roman number. For example: suppose we have an integer number 5 so here 5 is the input integer number and the ... Read More

How to reverse a string using only one variable in JavaScript

Nikitasha Shrivastava
Updated on 14-Aug-2023 18:19:30

149 Views

In this problem statement, our target is to print the reverse string using only one variable and implement the solution with the help of Javascript. So we can solve this problem with the help of loops in Javascript. Understanding the problem The given problem is stating that we have given a string to which we have to reverse the string. In simple terms we can say that if we have the string “Hello World”, the reverse of this string will be “dlroW ,olleH”. Logic for the given problem In order to reverse the given ... Read More

Shortest distance between objects in JavaScript

Nikitasha Shrivastava
Updated on 16-Aug-2023 16:50:13

383 Views

In this problem we have to calculate and find the shortest distance between two given objects in Javascript. So we will write a function to do this operation and also we will see its time and space complexity. We must consider the positions and coordinates of the objects in some way. Understanding the Problem The problem says to find the shortest path between the two given objects. So we will use two coordinates. And define a function which will have four parameters. These parameters will represent the x and y coordinates of the two objects. Inside the function ... Read More

Group a sorted array based on the difference between current and previous elements in JavaScript

Nikitasha Shrivastava
Updated on 14-Aug-2023 18:10:05

352 Views

In the given problem statement we have to group a sorted array based on the difference between the current and previous elements with the help of Javascript functionalities. To group a sorted array based on the difference between the current and previous items we can iterate over the array and create a new array of groups. Understanding the Problem Statement The above problem statement states that we have to find out the group of elements based on the difference between the current and previous elements in the array. As we have given a sorted array so we need ... Read More

Highest and lowest value difference of array JavaScript

Nikitasha Shrivastava
Updated on 14-Aug-2023 18:14:24

394 Views

In this problem we have to create an algorithm to get the highest and lowest value difference of an array with the help of Javascript functionality. So we will solve the problem with for loop and initialization of highest and lowest values to Infinity. Understanding the logic of the problem statement The problem statement is asking to write the code for getting the highest and lowest value difference of the array. So for solving this task we will initialize two variables, these variables will store the highest and lowest values. And then iterate through every element ... Read More

JavaScript Sum odd indexed and even indexed elements separately and return their absolute difference

Nikitasha Shrivastava
Updated on 14-Aug-2023 18:32:35

1K+ Views

In this problem we will understand how to get the absolute difference of the sum of odd indexed and even indexed items separately with the help of Javascript functionalities. We will use a simple loop to iterate through all the elements of the array. Understanding the problem statement To understand the above problem statement we will break down the problem step by step: So we are given an array of numbers. Our task is to separate the items in the array in two groups: first ... Read More

Average with the Reduce Method in JavaScript

AmitDiwan
Updated on 11-Aug-2023 16:14:19

709 Views

In the given problem statement, our aim is to get the average of all the items with the help of the reduce method of Javascript. So for doing this task we will create a function and give an array as a parameter. Understanding the problem statement We have given a task to calculate the average value of the given items in the array. And we have to use the reduce method which is a predefined method of Javascript. For example if we have an array as [1, 2, 3, 4, 5], so the average value of the ... Read More

Advertisements