gpt-3.5-turbo-0125· OpenAI
WildChat-4.8M (AI2)
Write a function that simply repeats the string a given number of times:…
- User
Write a function that simply repeats the string a given number of times:
repeatString('hey', 3) // returns 'heyheyhey'
- Assistant
function repeatString(str, num) { let repeatedString = ''; for (let i = 0; i < num; i++) { repeatedString += str; } return repeatedString; }
console.log(repeatString('hey', 3)); // 'heyheyhey'