Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let words = gets().split(', ');//най-важния ред от кода:)
- let wpPage = +gets();
- let key = gets();
- let currentPage = 1;
- let counter = 0
- let outPut = [] //Тука се съхраняват страниците
- for(let word of words){
- if((word == key)){
- outPut.push(currentPage)
- }
- counter ++
- if (counter === wpPage){
- currentPage++
- counter = 0
- }
- }
- outPut.push(-1) // ако не е открита думата се пушва -1
- outPut = outPut.sort((a,b) => b-a) //сортира се низходящо
- console.log(outPut[0]);
Advertisement
Add Comment
Please, Sign In to add comment