Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Check for Play Card
- // Play card
- // Description
- // 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.
- // Input
- // On the only line you will receive a single string.
- // Output
- // Output "yes CONTENT_OF_STRING" if the string is a card sign, otherwise print "no CONTENT_OF_STRING".
- // Constraints
- // String length will always be between 1 and 5
- // Sample tests
- // Input Output
- // 5 yes 5
- // 1 no 1
- // Q yes Q
- // q no q
- // P no P
- // 10 yes 10
- // 500 no 500
- const input = ['A'];
- const print = this.print || console.log;
- const gets = this.gets || ((arr, index) => () => arr[index++])(input, 0);
- const char = gets();
- 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') {
- print(`yes ${char}`);
- } else print(`no ${char}`);
Advertisement
Add Comment
Please, Sign In to add comment