Advertisement
Guest User

task

a guest
Jul 9th, 2020
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. You are given a list of roles as an array and a play script as a string.
  2. Each line of the play script is given as follows: <Role: text>.
  3. The text can contain any characters.
  4. Create a function that will regroup the lines according to roles, number them and return the result in the form of ready-made text (see example). Each group is displayed as follows:
  5.  
  6. Role:
  7. i) text
  8. j) text2
  9. ...
  10. == line break ==
  11. i and j are line numbers in the script. Line indexing starts with one, the groups should be displayed in accordance with the order of roles. Line breaks between groups are required, line breaks at the end of the text are not taken into account.
  12.  
  13. Sample Input:
  14. roles:
  15. [ "Городничий", "Аммос Федорович", "Артемий Филиппович", "Лука Лукич"]
  16.  
  17. textLines:
  18. `Городничий: Я пригласил вас, господа, с тем, чтобы сообщить вам пренеприятное известие: к нам едет ревизор.
  19.     Аммос Федорович: Как ревизор?
  20.     Артемий Филиппович: Как ревизор?
  21.     Городничий: Ревизор из Петербурга, инкогнито. И еще с секретным предписаньем.
  22.     Аммос Федорович: Вот те на!
  23.     Артемий Филиппович: Вот не было заботы, так подай!
  24.     Лука Лукич: Господи боже! еще и с секретным предписаньем!`
  25.  
  26. Sample Output:
  27. Городничий:
  28. 1) Я пригласил вас, господа, с тем, чтобы сообщить вам пренеприятное известие: к нам едет ревизор.
  29. 4) Ревизор из Петербурга, инкогнито. И еще с секретным предписаньем.
  30.  
  31. Аммос Федорович:
  32. 2) Как ревизор?
  33. 5) Вот те на!
  34.  
  35. Артемий Филиппович:
  36. 3) Как ревизор?
  37. 6) Вот не было заботы, так подай!
  38.  
  39. Лука Лукич:
  40. 7) Господи боже! еще и с секретным предписаньем!
  41.  
  42. const textForRole = (roles, textLines) => {};
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement