To manipulate JavaScript’s Date object, you can either use get or set method and properties. For example, to set hours or to get minutes in JavaScript. Once a Date object is created, a number of methods allow you to operate on it. Most methods simply allow you to get and set the year, month, day, hour, minute, second, and millisecond fields of the object, using either local time or UTC (universal, or GMT) time. Here is a list of the methods used to Date and their description. Sr.No Methods & Description 1 date() Returns today's date ... Read More
This tutorial will discuss how to write swift program to find the geometric mean of the numbers. Geometric mean also known as GM. Geometric mean is defined as the xth root of the product of x numbers. Suppose we have x elements(that are, a1, a2, a3, ....ax) in the given array, then the geometric mean is − GM = (a1 * a2 * a3 * a4 * ....*ax)1/x Below is a demonstration of the same − Input Suppose our given input is − MyVal = [34, 67, 2, 45, 8, 12] Output The desired output would be − Geometric ... Read More
This tutorial will discuss how to write swift program to find the harmonic mean of the numbers. Harmonic mean also known as HM is defined as the reciprocal of the average of reciprocal. Or we can say that harmonic mean is the reciprocal of the arithmetic mean by their reciprocal. Suppose a1, a2, a3, a4, .....an are the n-elements of a collection then the harmonic means is − HM = n/[(1/a1) + 1/(a2) + 1/(a3) + 1/(a4)+...+ 1/(an)] Below is a demonstration of the same − Input Suppose our given input is − MyVal = [3.4, 1.2, 7.8, 4.5, 2.4] ... Read More
This tutorial will discuss how to write swift program to find median of an unsorted array. An array is an ordered collection which is used to store same type of data. For example, if any array is of integer type then it will only store integers, you are strictly not allowed to store elements of other data types like string, float, etc. Syntax Following is the syntax for an array − var array1 = [val1, val2, val3, …] Or var array2 = [Type]() Median represent the middle value of the given sorted set of numbers. We can calculate the ... Read More
This tutorial will discuss how to write swift program to find mean of an unsorted array. An array is an ordered collection which is used to store same type of data. For example, if any array is of integer type then it will only store integers, you are strictly not allowed to store elements of other data types like string, float, etc. Syntax Following is the syntax for an array − var array1 = [val1, val2, val3, …] Or var array2 = [Type]() Mean represent the average of the given numbers. It is calculated by dividing the sum of ... Read More
This tutorial will discuss how to write swift program to calculate the sum of elements in a given array. An array is an ordered collection which is used to store same type of data. For example, if any array is of integer type then it will only store integers, you are strictly not allowed to store elements of other data types like string, float, etc. Syntax Following is the syntax for an array − var array1 = [val1, val2, val3, …] Or var array2 = [Type]() Suppose we have an array of integer type: [20, 30, 40, 50]. Now ... Read More
This tutorial will discuss how to write swift program to get the magnitude of the number. An array is an ordered collection which is used to store same type of data. For example, if any array is of integer type then it will only store integers, you are strictly not allowed to store elements of other data types like string, float, etc. To remove all the elements from the specified array Swift provide an in-built library function named removeAll(). The removeAll() function will delete all the items from the specified array. Or it can delete elements that match the given ... Read More
This tutorial will discuss how to write swift program to remove an element from the set. Set is a primary collection type in Swift. It is an unordered collection which stores unique values of same data type. You are not allowed to store different type of values in the same set. A set can be mutable or immutable. To remove an element from the set Swift provide an in-built library function named remove(). The remove() function delete the given element from the specified set. If the given element is not the part of the specified set, then it will return ... Read More
This tutorial will discuss how to write swift program to add a new element in the set. Set is a primary collection type in Swift. It is an unordered collection which stores unique values of same data type. You are not allowed to store different type of values in the same set. A set can be mutable or immutable. To add a new element in the set Swift provide the following functions − insert() update() Below is a demonstration of the same − Input Suppose our given input is − MySet = [23, 45, 1, 46, 2] Insert ... Read More
This tutorial will discuss how to write swift program to convert a string to uppercase. A string is a sequence of characters for example, “RedCar”. Or we can say, string are used to represent textual data. Swift support a String data type which is used to create a String type variable, or we can say to represent strings. To convert the given string into uppercase Swift provide a in-built function named uppercased(). The uppercased() function is used to convert all the characters(either in lowercase or in uppercase or in both) of the given string into uppercase. This function does not ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP