JS: String.prototype.split()

The String.prototype.split() function divide the string into array of sub-strings. You can perform other array manipulation on the resultant string.The syntax for split() function is given below.Separator – it is a character that is used to separate the sub-strings. It is optional, however, a separator is required to divide the sub-strings.Limit – it is the … Read more

JS: String.prototype.endsWith()

The JavaScript String.prototype.endsWith() function will receive a string as parameter and check if the given string ends with the parameter string. If it does end with parameter string, returns true otherwise, returns false.The syntax to use endsWith() is given below.The string “ond” is matched with “My name is James Bond” and if the string ends … Read more

Repeat A String

Previous Next In JavaScript, there are several in-built functions to manipulate strings. One of them is String.prototype.repeat() function. In this tutorial, you will write a program that will repeat a string for a given number of times.The steps that this program follows is given below: JavaScript function receives an input string and a number as … Read more

Find The Largest Number

Previous Next In this example, we will receive a two-dimensional array of numbers as input and the JavaScript function will find the largest in each sub-array and return the result in a new array.The program takes following steps to compute the results: Receive an array with many sub-arrays. Set a maximum number variable. Loop through … Read more

Find Longest Word in a String

Previous Next In this example, you will create a JavaScript function that will accept a string that contains multiple words and find the longest among those words and display the length of the string.The program takes following steps to find the longest string. Accept the string in a function – findLengthLongest(). Use JavaScript regex to … Read more

Reverse a String

Previous Next In this example, we will create a program using JavaScript and HTML to reverse a given string and display the output.The JavaScript code will accept a string from a HTML textbox control and reverse the string and output the result to a H1 element to display.The step to reverse the string is given … Read more

Find Factorial Of A Number

Previous Next The factorial is a popular mathematical concept or algorithms and very useful in computer science. In this example, we are going to accept a number as argument to JavaScript function and find the factorial of the number. To accept the argument, we will use HTML text box control and output it in a … Read more

Celsius To Fahrenheit

Previous Next In this example , we will test a simple algorithms to convert temperature in Celsius to Fahrenheit and display on a HTML page.The step to convert from Celsius to Fahrenheit is given below. Receive input from a HTML text box. When user click the button to convert Celsius to Fahrenheit, execute JavaScript function … Read more

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Exit mobile version