Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(args) {
- let email = args.shift();
- let lineInput = args.shift();
- while (lineInput !== 'Complete') {
- const [command, arg1] = lineInput.split(' ');
- switch (command) {
- case 'Make':
- if (arg1 === 'Upper') {
- email = email.toUpperCase();
- console.log(email);
- } else if (arg1 === 'Lower') {
- email = email.toLowerCase();
- console.log(email);
- }
- break;
- case 'GetDomain':
- const srt = email.slice(0, email.length - Number(arg1));
- const lastCount = email.slice(srt.length - 1 + 1);
- console.log(lastCount);
- break;
- case 'GetUsername':
- if (email.includes('@')) {
- const takeIndexStr = email.indexOf('@');
- const takeUserName = email.slice(0, takeIndexStr);
- console.log(takeUserName);
- } else {
- console.log(`The email ${email} doesn't contain the @ symbol.`);
- }
- break;
- case 'Replace':
- while (email.includes(arg1)) {
- email = email.replace(arg1, '-');
- }
- console.log(email);
- break;
- case 'Encrypt':
- const toAcii = email.split('')
- .map((chr) => chr.charCodeAt())
- .join(' ');
- console.log(toAcii);
- break;
- default:
- break;
- }
- lineInput = args.shift();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement