Posts for Ariessa Norramli

Programmer | Writer | bitsized dot me at gmail dot com

How to Truncate A String in Javascript

In this article, you will learn how to truncate a string in Javascript. Let’s say you have a string variable named ‘a’ with value “I love code-source.tempurl.host!”. In order to truncate a string, you can use the substring() method. In this example, you will be extracting the first 6 characters from ‘a’. Note: The substring() […]

February 17, 2021 in Code examples

How to Reverse A String in Javascript

In this article, you will learn how to reverse a string in Javascript. Let’s say you have a string variable named ‘a’ with value “codesource”. In order to reverse the string variable, you can use the split(), reverse() and join() methods. Note: The split() method functions by splitting a string into an array of substrings. […]

February 17, 2021 in Code examples

How to Compare Dates in Javascript

In this article, you will learn how to Compare Dates in Javascript. Let’s say you have two dates: 14 / 2 / 2020 and 14 / 2 / 2021. In order to compare dates, you can use the getTime() method and a strict equality comparison ===. Note: The getTime method functions by returning the number […]

February 14, 2021 in Code examples

How to Capitalize Strings in JavaScript

In this article, you will learn How to Capitalize Strings in JavaScript. Let’s say you have a string variable named ‘a’ with the value “codesource”. In order to capitalise the value of a, you can use the toUpperCase() method. Note: The toUpperCase() method functions by converting all alphabetical characters in a string to uppercase letters.

February 14, 2021 in Code examples