Advertisement
Guest User

Untitled

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