Well, there are multiple methods to do this.
Let’s say the number was 5
.
The first method would be to use the String
function, rather than str
String(5) // this should equal "5"
The second method would be to add the 5 with a string. When you add a number with a string, the number is automatically converted to a string, which is kinda nice. In the example below, I added (or rather, joined ) an empty string ""
with the number 5
""+5 // this should equal "5"
(Fun fact, you can also convert a string to a number by multiplying it by 1, or using the Number
function)