Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function helloSoftUni(input) {
- let nTickets = Number(input.shift());
- let output = "";
- let output2 = "";
- let firstChar = 0;
- let secondChar = 0;
- let thirdChar = 0;
- let fourthChar = 0;
- let fifthChar = 0;
- let sixtChar = 0;
- let ticketCode = "";
- regexp = /^[A-Z]/;
- for (let index = 1; index <= nTickets; index++) {
- ticketCode = input.shift();
- firstChar = ticketCode.charAt(0);
- if (firstChar.toUpperCase == firstChar) {
- secondChar = ticketCode.charAt(1);
- thirdChar = ticketCode.charAt(2);
- fourthChar = ticketCode.charAt(3);
- fifthChar = ticketCode.charAt(4);
- sixthChar = ticketCode.charAt(5);
- if (fifthChar == 0) {
- output = `Seat decoded: ${firstChar}${secondChar}${thirdChar}`
- } else {
- secondChar = secondChar.charCodeAt(0);
- output = `Seat decoded: ${firstChar}${secondChar}`
- }
- }
- else {
- secondChar = ticketCode.charAt(1);
- thirdChar = ticketCode.charAt(2);
- fourthChar = ticketCode.charAt(3);
- fifthChar = ticketCode.charAt(4);
- sixthChar = ticketCode.charAt(5);
- if (fifthChar == 0) {
- output = `Seat decoded: ${fourthChar}${secondChar}${thirdChar}`
- } else {
- secondChar = secondChar.charCodeAt(0);
- output = `Seat decoded: ${firstChar}${secondChar}`
- }
- console.log(output)
- }
- }
- // console.log(secondChar)
- }
- helloSoftUni(["3",
- "042W",
- "W981",
- "W24578"
- ])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement