Capslock01's Posts
Nairaland Forum › Capslock01's Profile › Capslock01's Posts
1 2 3 4 5 6 7 8 9 10 (of 12 pages)
Capslock01:// Day 3 Solution function takesArray (theArray) { let arrTakes = []; for (let element of theArray) { for (let i = 0; i <= element; i++) { if (i === 0) { arrTakes.push() } else if (i % 5 === 0 && i % 3 === 0) { arrTakes.push('FizzBuzz'); } else if ( i % 5 === 0) { arrTakes.push('Buzz'); } else if (i % 3 === 0) { arrTakes.push('Fizz'); } else { arrTakes.push(i); } } } const outputArray = console.log([arrTakes]); } takesArray([4,15,6]) PS: This code is not as optimized as I wanted it to be. The output gave the required results but it's not as packed as the challenge require. I'll appreciate if anyone can post a more optimized solution or give a pointer to how things can be done perfectly. Thank you |
Day 3 FizzBuzz Pro Max Write a function that takes an array of numbers and returns an array that contains arrays where each array contains the output that would have been spat out if the FizzBuzz function was called on the number [4, 10, 6] => [[1,2,Fizz,4], [1,2,Fizz,4,Buzz,Fizz,7,8,Fizz,Buzz], [1,2,Fizz,4,Buzz,Fizz]] |
qtguru:Wow! Thanks for dropping by qtguru. And thanks for the compliment too. Yeah, you're right! Like what I've learned in the few days I started this challenge is really amazing. Even things I know before are better understood solving some questions of the challenge. |
Deicide:Oh! You're right. I never thought of it. But then, if I had thought of it. I'd have avoided it because the challenge is to avoid built in method to get some things done. Like in Day 7. Which is today's task. It was asked to sort an unorganized array without using the sort() method. |
LikeAking:Lol. I'm not copying answers from the internet BUT whenever I'm stuck, I look up things but I do not copy and dump codes. I feel looking things up on stackoverflow and other platform is part of learning process and programming. BUT I do not copy and dump codes Thank you so much. You're also welcome to drop any solution even to the ones I've done. If there's a better way of doing things. |
Deicide:Kind of. But; I've got knowledge of how things work. As I've done some basic projects with it though. |
Imoleholuuu:Hi, You can check my last thread. And hoop in on the challenge. It'll help you practice all what you've learned. And also, you can holler at me if you need a partner that will hold you accountable to the learning. |
Capslock01:// Day 2 Solution // Fizz, Buzz, FizzBuzz function counter (numberInput) { for (let i = 0; i <= numberInput; i++) { if (i % 3 === 0 && i % 5 === 0) { console.log('FizzBuzz'); } else if ( i % 5 === 0) { console.log('Buzz'); } else if (i % 3 === 0) { console.log('Fizz'); } else { console.log(i); } } } counter(15) |
Day 2 FizzBuzz Create a function that takes an integer as its input. The function should print all numbers from 1 to n but follow these rules as well: - If the number is divisible by 3, print Fizz in its place - If the number is divisible by 5, print Buzz in its place - If divisible by both 3 and 5, print FizzBuzz For example: Input => 3 Output => 1 2 Fizz Input => 15 Output => 1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz |
Capslock01:// Day 1 Solution const sumArray = function (Array) { let sum = 0; for (let i = 0; i < Array.length; i++) { sum += Array[i]; } console.log(sum); } const arrayToAdd = [1, 2, 3 , 8]; //Output 14 const arrayToAdd1 = [9, 19, 73] //101 sumArray(arrayToAdd); sumArray(arrayToAdd1) |
Day 1 Array Sum Create a function that calculate the sum of an array. The function should receive an array as it's parameter and return the sum of the numbers in that array. For example: sumOfArray([1, 5, 4]) // returns 10; sumOfArray([1, 2, -3, 5]) // returns 5; |
Hi all, I'd be documenting the 30 days challenge of JavaScript I just joined, though the challenge is now at day 7 but it's never late. PS: I'm just way below average JavaScript user with no experience. Hence, most codes here will not be too refined or optimized. I'd appreciate all suggestions to make my codes more optimized. |
oluphemmxzy:40k Lagos Pictures ![]() |
Lexusgs430:Hello sir, How much are you selling? |
Who has Umidigi up for sale? |
Portableteewhy:What's the battery health? 104k? |
Still very clean as new. No issue. 4GB, 128GB Sold |
Do you think Upwork is biased? I was strolling through Upwork and I saw this guy that just joined Upwork. He has not yet finished any job and Upwork gave him raising talent badge. What do you think? Is Upwork biased?
|
harkinlaby77 when you have X, please mention me. Thank you |
Please who knows if CBN policy is affecting Payoneer to Bank withdrawal. I've been trying to withdraw since last week. The fund did not drop in my local bank for days after which it was reverted to my Payoneer wallet stating that bank account detail is incorrect. NB: I copy and pasted the right bank account details |
Hello, I'm currently working on a model, I've done the bulb of work on it but I need someone to help me pose it as I'm occupied. I'm looking for someone that can sincerely get this done with quick turnaround. Please comment, I'll reach out. Picture 1 is what is needed to get done. And picture 2 is current model
|
. |
Bigman101:Print this and give it to your friend. Lol. "It's not how less he sleeps but what he does when he's awake" That consistent 1 to 3 hours is enough to get him on track! |
. |
Brightale:With or without space, it'll still run. The issue with his code was not having curly bracket set. |
Think4Myself:The issue you're having is that JavaScript script return input as a string. You can check this with console.log(typeof principal); console.log(typeof rate); console.log(typeof time); You'll see it'll return "string" So, to fix your issue. Add "Number" to your declaration, it's case sensitive. Like var principal = Number(document. getElementById('p').value); Do that for other declaration. It should work. |
Start like this! HTML5 CSS JavaScript. They're more like same thing but HTML5 is less strict than XHTML. Exclude XHTML abeg |
africanman85:I executed it on my PC and it ran. Probably the "avgDolphins" and "avgKoalas" has already been declared in your local variable, if it was declared in the global variable you would have gotten error. I modified the code already and I tested it. It worked. you can check below: //Q1You can post more questions/challenge |
const calcAverage1 = function (dolphins1, dolphins2, dolphins3) { const avgDolphins = (dolphins1 + dolphins2 + dolphins3)/3; console.log('Dolphins Average is ---> ' + avgDolphins) } avgDolphins = calcAverage1 (44, 23, 71); //Test for Data 1 --- "Value is 46" const calcAverage2 = function (Koalas1, Koalas2, Koalas3) { const avgKoalas = (Koalas1 + Koalas2 + Koalas3)/3; console.log('Koalas Average is ---> '+ avgKoalas) } avgKoalas = calcAverage2 (65, 54, 49); //Test for Data 2 --- "Value is 56" //This code takes Average as parameters function checkWinner (avgDolphins, avgKoalas) { if (avgDolphins >= 2*avgKoalas) { console.log (`Delphins win (${avgDolphins} vs ${avgKoalas})`); } else if (avgKoalas >= 2*avgDolphins) { console.log (`Koalas win (${avgDolphins} vs ${avgKoalas})`); } else { console.log('No team win') } } checkWinner(46, 56) //Test for Data 1 Average I hope this help. I will try to help you to refine the code tomorrow. |
flex04:Go to the folder and run CMD .exe from there |
I start less than a week with a paid course on Udemy! I feel paying for the course will motivate me to complete it. I'm interested! Though I might not be able to dedicate 10 hours because of my job. . Please don't quote, so that I'd be able to edit my number after we're connected. |
