Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function odd(num){
- let count = 0;
- let sum = 0;
- for (let i=1; i <= 100; i++){
- if (i % 2 == 1) {
- console.log(i);
- count++;
- sum += i;
- if (count==num){
- break;
- }
- }
- }
- console.log(`Sum: ${sum}`)
- }
Advertisement
Add Comment
Please, Sign In to add comment