How would I do something like this in javascript:
var s = '124sdg'; var f = 'hsdsda'; if (s.startsWith(a number)) { // Return true } if (f.startsWith(a number)) { // Return false } You can use a regular expression:
if (s.match(/^\d/)) { // Return true } if (f.match(/^\d/)) { // Return false } .test performs better. Please refer here.test is better here.