Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 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β if it is a valid card sign or βnoβ otherwise.
- //
- //Examples:
- //character Valid card sign?
- // 5 yes
- // 1 no
- // Q yes
- // q no
- // P no
- // 10 yes
- // 500 no
- let input = ['500'];
- let print = this.print || console.log;
- let gets = this.gets || ((arr, index) => () => arr[index++])(input, 0);
- //Get the character
- let char = gets();
- if(char >= 2 && char <= 10) {
- console.log(`yes`);
- } else if(char === 'J' || char === 'Q' ||char === 'K' ||char === 'A'){
- console.log(`yes`);
- } else {
- console.log('no');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement