0

Pls I need help on improving the performance of my code in terms of time and space complexity.

The code calculates the total annual income a man earns. But I would like this code to be rewritten with improved performance in mind. Pls I want solutions only in Javascript. Thanks a lot as you try to help out. https://code.sololearn.com/Wef90Pb81PGF/?ref=app

24th Apr 2021, 9:32 PM
Okafor Okwuchukwu Charisma
Okafor Okwuchukwu Charisma - avatar
3 odpowiedzi
+ 1
okafor okwuchukwu charisma You can avoid the for loop if you do this: const text = 'He earns 5000 euro from salary per\ month, 10000 euro annual bonus, 15000 euro\ online courses per month.'; const arr = text.match(/\d+/g); const totalAnnualIncome = (+arr[0] + +arr[2]) * 12 + +arr[1]; console.log(totalAnnualIncome);
24th Apr 2021, 10:24 PM
CamelBeatsSnake
CamelBeatsSnake - avatar
+ 1
Thanks a lot, you are always the first to help me out. I so much appreciate your kindness.
25th Apr 2021, 1:30 PM
Okafor Okwuchukwu Charisma
Okafor Okwuchukwu Charisma - avatar
+ 1
okafor okwuchukwu charisma Thank you. That's very nice of you to say so. All the best with your learning.
25th Apr 2021, 1:56 PM
CamelBeatsSnake
CamelBeatsSnake - avatar