alboig

CheckForPlayCard - JavascriptModule0

Apr 14th, 2020
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Check for Play Card
  2. // Play card
  3. // Description
  4. // Classical play cards use the following signs to designate the card face: 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K and A. Write a program that enters a string and prints "yes CONTENT_OF_STRING" if it is a valid card sign or "no CONTENT_OF_STRING" otherwise.
  5.  
  6. // Input
  7. // On the only line you will receive a single string.
  8. // Output
  9. // Output "yes CONTENT_OF_STRING" if the string is a card sign, otherwise print "no CONTENT_OF_STRING".
  10. // Constraints
  11. // String length will always be between 1 and 5
  12. // Sample tests
  13. // Input Output
  14. // 5 yes 5
  15. // 1 no 1
  16. // Q yes Q
  17. // q no q
  18. // P no P
  19. // 10 yes 10
  20. // 500 no 500
  21. const input = ['A'];
  22. const print = this.print || console.log;
  23. const gets = this.gets || ((arr, index) => () => arr[index++])(input, 0);
  24. const char = gets();
  25. if (char === '2' || char === '3' || char === '4' || char === '5' || char === '6' || char === '7' || char === '8' || char === '9' || char === '10' || char === 'J' || char === 'Q' || char === 'K' || char === 'A') {
  26.   print(`yes ${char}`);
  27. } else print(`no ${char}`);
Advertisement
Add Comment
Please, Sign In to add comment