79502503

Date: 2025-03-12 02:19:10
Score: 0.5
Natty:
Report link

Can use charAt(0) === '0' or startsWith('0'). Both work to check if the first character is '0'

var str = "01234"; // Example string
if (str.charAt(0) === '0') {
 console.log("First character is 0");
} else {
 console.log("First character is not 0");
}

var str = "01234"; // Example string
if (str.startsWith('0')) {
    console.log("First character is 0");
} else {
    console.log("First character is not 0");
}
Reasons:
  • Has code block (-0.5):
  • Starts with a question (0.5): Can u
  • Low reputation (0.5):
Posted by: Mohaimin Moin