Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve() {
- let text = Array.from(document.querySelector('#text').value)
- let number = +document.querySelector('#number').value;
- let result = document.querySelector('#result')
- let validKeys = [];
- if(text.join('').match(new RegExp(`.{${number}}`,'g')) === null){
- let output = []
- while(output.length < number){
- text.forEach(x=> output.push(x))
- }
- result.textContent = output.join('')
- }else{
- text = text.join('').match(new RegExp(`.{${number}}`,'g')).join(' ')
- validKeys.push(text)
- result.textContent = validKeys.join('')
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement