Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. function helloSoftUni(input) {
  2. let nTickets = parseInt(input.shift());
  3. let output = "";
  4. let output2 = "";
  5. let firstChar = "";
  6. let secondChar = 0;
  7. let thirdChar = 0;
  8. let fourthChar = 0;
  9. let fifthChar = 0;
  10. let sixtChar = 0;
  11. let ticketCode = "";
  12. for (let index = 1; index <= nTickets; index++) {
  13. ticketCode = input.shift();
  14. firstChar = ticketCode[0];
  15. //let up = /[A-Z]/.test(firstChar);
  16. //console.log(up)
  17. if (/[A-Z]/.test(firstChar)) {
  18. secondChar = ticketCode.charAt(1);
  19. thirdChar = ticketCode.charAt(2);
  20. fourthChar = ticketCode.charAt(3);
  21. fifthChar = ticketCode.charAt(4);
  22. sixthChar = ticketCode.charAt(5);
  23. if (fifthChar == 0) {
  24. output = `Seat decoded: ${firstChar}${secondChar}${thirdChar}`
  25. } else {
  26. secondChar = secondChar.charCodeAt(0);
  27. output = `Seat decoded: ${firstChar}${secondChar}`
  28. }
  29. }
  30. else {
  31. secondChar = ticketCode.charAt(1);
  32. thirdChar = ticketCode.charAt(2);
  33. fourthChar = ticketCode.charAt(3);
  34. fifthChar = ticketCode.charAt(4);
  35. sixthChar = ticketCode.charAt(5);
  36. if (fifthChar == 0) {
  37. output = `Seat decoded: ${fourthChar}${secondChar}${thirdChar}`
  38. } else {
  39. secondChar = secondChar.charCodeAt(0);
  40. output = `Seat decoded: ${firstChar}${secondChar}`
  41. }
  42. }
  43. console.log(output)
  44.  
  45.  
  46. }
  47.  
  48. // console.log(secondChar)
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement