-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDay46.js
More file actions
25 lines (20 loc) · 1.26 KB
/
Day46.js
File metadata and controls
25 lines (20 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//*
//* Programming Challenge: Mobile Number Validation
//*-
//? Write a function that takes a string as input and returns true if the string repres a valid Indian mobile number, and false otherwise.
//* Validation Requirements:
//? Length: An Indian mobile number should have exactly 10 digits.
//? Starting Digit: The number must start with 6, 7, 8, or 9, which are valid starting digits for Indian mobile numbers.
// Test Cases
function validateIndianMobileNumber(number) {
// Regular expression to match Indian mobile numbers
var regex = /^[6-9]\d{9}$/;
// Test the input number against the regex
return regex.test(number);
}
// Test Cases
console.log(validateIndianMobileNumber("9876543210")); // Expected output: true
console.log(validateIndianMobileNumber("0123456789")); // Expected output: false
console.log(validateIndianMobileNumber("897654321")); // Expected output: false
console.log(validateIndianMobileNumber("78965432107")); // Expected output: false
console.log(validateIndianMobileNumber("9876543210")); // Expected output: true console.log(validateIndianMobileNumber("0123456789)); // Expected output: false console.log(validateIndianMobileNumber("897654321" )); // Expected output: false console.log(validateIndianMobileNumber("78965432107"));