DEV Community

Natália Catunda
Natália Catunda

Posted on

Strings and Numbers on JS, pills...

Image description
Hi these are some pills(little conceptional parts) that you can use daily bases of your programmer's life.
So i compill all of Strings to Numbers and Numbers to Strings functions and proprieties that we can use for it in javascript language.

_Strings_to Numbers

  • First pill use String() :
let number="55 86 4232 5267";
console.log("My cellphone number is" + String(number));

Enter fullscreen mode Exit fullscreen mode
  • Second pill use .toString() ::

let number="55 86 4232 5267";
console.log("my cellphone number is" + number.toString());

Enter fullscreen mode Exit fullscreen mode

Numbers to String

  • Thirth pill use Number:
let width = "90";
let height = "25";
console.log(Number(width) * Number(height));
Enter fullscreen mode Exit fullscreen mode
  • Fourth pill use +
let width = "9000";
let height = "80";
console.log( + width * + height);
Enter fullscreen mode Exit fullscreen mode

happy coding!! :))

Top comments (0)