Write a JavaScript program to check whether a given string represents a correct sentence or not. A string is considered correct sentence if it starts with the capital letter and ends with a full stop (.)

  • برمجة جافاسكربت java script
  • برمجة

Write a JavaScript program to check whether a given string represents a correct sentence or not. A string is considered correct sentence if it starts with the capital letter and ends with a full stop (.).

الأجوبة

function is_correct_Sentence(input_str) {
    var first_char = input_str[0];
    var last_char = input_str[input_str.length - 1];
    return /[A-Z]/.test(first_char) && last_char == "."
}
console.log(is_correct_Sentence("This tool will help you write better English and efficiently corrects texts."));
console.log(is_correct_Sentence("This tool will help you write better English and efficiently corrects texts"));            
console.log(is_correct_Sentence("this tool will help you write better English and efficiently corrects texts."));
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...