Write a JavaScript function to check whether a string is blank or not.Test Data :console.log(is_Blank(''));console.log(is_Blank('abc'));truefalse
Question
Write a JavaScript function to check whether a string is blank or not.Test Data :console.log(is_Blank(''));console.log(is_Blank('abc'));truefalse
Solution
Sure, here is a simple JavaScript function that checks whether a string is blank or not:
function is_Blank(input) {
if (input.length === 0)
return true;
else
return false;
}
console.log(is_Blank('')); // This will return true
console.log(is_Blank('abc')); // This will return false
This function, is_Blank, takes a string as an input. It checks the length of the string. If the length is 0, that means the string is blank, so it returns true. If the length is not 0, that means the string is not blank, so it returns false.
Similar Questions
Which Excel formula would you use to find out if a specific cell is blank or not?=BLANK=ISEMPTY=ISBLANK
Which of the following is a falsy value in JavaScript?Options[ ] (empty array)"false" (string)0 (number)true (boolean)
A NULL value is treated as a blank or 0.Question 6Select one:TrueFalse
Which of the following is a falsy value in JavaScript?Options0 (number)"false" (string)true (boolean)[ ] (empty array)
Which of the following is a falsy value in JavaScript?Options0 (number)true (boolean)[ ] (empty array)"false" (string)
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.