Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An object is in "such state" functions #2

Open
Michaelh818 opened this issue Apr 29, 2019 · 0 comments
Open

An object is in "such state" functions #2

Michaelh818 opened this issue Apr 29, 2019 · 0 comments

Comments

@Michaelh818
Copy link
Contributor

An object is in "such state" functions:

  1. Come in the form of questions we can answer yes or no to. Like is the integer prime?, is the string a palindrome?, etc.
function isPrime(num) {
    for ( var i = 2; i < num; i++ ) {
      if ( num % i === 0 ) {
        return false;
      }
    }
    return true;
  }
function isPalindrome(str) {
  var strR =str.split("").reverse().join("");
  return strR === str;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant