Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Write a program that, depending on the user’s choice, inputs a number, boolean or string variable.
- // * If the variable is number, the program increases it by one. * If the variable is boolean,
- // the program swaps it with its counterpart. * If the variable is a string,
- // the program appends * at the end. * Print the result at the console. Use switch statement.
- let input = ['1', '3'];
- let print = this.print || console.log;
- let gets = this.gets || ((arr, index) => () => arr[index++])(input, 0);
- let userChoice = +gets();
- let userInput = gets();
- switch (userChoice) {
- case 1:
- print(`Please enter a number: ${userInput}`);
- print(`${Number(userInput) + 1}`);
- break;
- case 2:
- print(`Please enter a boolean: ${userInput}`);
- print(!userInput);
- break;
- case 3:
- print(`Please enter a string: ${userInput}`);
- print(`${userInput}*`);
- break;
- default:
- break;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement