I just want to get a number from the string "Hello, I'm 24 years old" in JavaScript How can you do that?
javascript
You can import it using a regular expression.
var str = "Hi, I'm 24 years old";
var num = str.replace(/[^0-9]/g,"");
You can do it like this.
© 2024 OneMinuteCode. All rights reserved.