I have my java script in angular checking if the value of text field is undefined or empty, it is fine and working,
$scope.checkNumber = function(user_answer){
if(user_answer == undefined){
return false;
}
}
But my next step is how I can make a function to identify if the value has a string or a number and return a boolean. I don't know the right syntax for angular java script, can anyone help me to solve my problem?
You can do this the angular way, using the angular helper functions:
$scope.checkNumber = function(user_answer){
if(angular.isUndefined(user_answer)){
return false;
}
if(angular.isString(user_answer)) {
//return boolean
}
if(angular.isNumber(user_answer)) {
//return boolean
}
}
Try like this
function check(text){
return typeof text ==="number";
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With