Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,153,010 members, 7,817,977 topics. Date: Sunday, 05 May 2024 at 01:07 AM

Capslock01's Posts

Nairaland Forum / Capslock01's Profile / Capslock01's Posts

(1) (2) (3) (4) (5) (6) (7) (8) (9) (10) (of 12 pages)

Programming / Re: Dairy Of Javascript Challenge by Capslock01: 11:12pm On Apr 11, 2022
Capslock01:
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]]


// 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
Programming / Re: Dairy Of Javascript Challenge by Capslock01: 11:06pm On Apr 11, 2022
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]]
Programming / Re: Dairy Of Javascript Challenge by Capslock01: 10:59pm On Apr 11, 2022
qtguru:
I think you are doing well keep up the thread, you will learn about reduce and the rest as time goes on, I think everyone learning should create a thread to track their progress.

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.
Programming / Re: Dairy Of Javascript Challenge by Capslock01: 5:38pm On Apr 11, 2022
Deicide:
I was just wondering why you didn't use the reduce function for the Array sum

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.
Programming / Re: Dairy Of Javascript Challenge by Capslock01: 5:29pm On Apr 11, 2022
LikeAking:


I hope u ar not copying ans from d web, some spying things.

Any way you are doing good.



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.
Programming / Re: Dairy Of Javascript Challenge by Capslock01: 4:07pm On Apr 11, 2022
Deicide:
Are you new to JavaScript?

Kind of.
But;
I've got knowledge of how things work.
As I've done some basic projects with it though.
Programming / Re: Javascript Help!!! by Capslock01: 1:19pm On Apr 11, 2022
Imoleholuuu:
What is the best way to learn Javascript. I've been on it for a while now without understanding anything. I don't want to give up.

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.
Programming / Re: Dairy Of Javascript Challenge by Capslock01: 12:15pm On Apr 11, 2022
Capslock01:
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

// 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)
Programming / Re: Dairy Of Javascript Challenge by Capslock01: 11:44am On Apr 11, 2022
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
Programming / Re: Dairy Of Javascript Challenge by Capslock01: 11:40am On Apr 11, 2022
Capslock01:
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;

// 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)

2 Likes

Programming / Re: Dairy Of Javascript Challenge by Capslock01: 11:37am On Apr 11, 2022
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;
Programming / Dairy Of Javascript Challenge by Capslock01: 11:34am On Apr 11, 2022
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.
Phones / Re: Redmi 8 Up For Sale by Capslock01: 9:24pm On Jan 07, 2022
oluphemmxzy:
I have a neatly used redmi 8 with carton for sale. 3/32gb ram/ROM.....

Reason for selling: want to upgrade
45k firm

40k Lagos
Pictures
Phones / Re: UMIDIGI DISCUSSION THREAD by Capslock01: 8:59am On Jan 07, 2022
Lexusgs430:


I have an Umidigi F1 (red)............

Hello sir,
How much are you selling?
Phones / Re: UMIDIGI DISCUSSION THREAD by Capslock01: 4:42pm On Jan 05, 2022
Who has Umidigi up for sale?
Phones / Re: Iphone X For Sale by Capslock01: 4:21pm On Dec 23, 2021
Portableteewhy:
Neatly used iPhone X 64gb with no Face ID for sale for 130k only(slightly negotiable)
What's the battery health?

104k?
Phone/Internet Market / Samsung A51 For Sale by Capslock01: 2:06pm On Nov 24, 2021
Still very clean as new.
No issue.
4GB, 128GB


Sold
Business / Re: Upwork Thread (Questions/Help/Advice) by Capslock01: 9:18am On Nov 22, 2021
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?

1 Like

Phone/Internet Market / Re: Iphone xr For Sale (sold) by Capslock01: 2:03pm On Nov 21, 2021
harkinlaby77 when you have X, please mention me.
Thank you
Business / Re: EXCLUSIVE : How To Make Level 2 Seller On Fiverr In A Month As A Nigerian Seller by Capslock01: 8:34pm On Oct 31, 2021
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
Art, Graphics & Video / Re: Who Can Finish UP This Model by Capslock01: 5:55am On Oct 06, 2021
OgogoroFreak:
I'll give you a "F"
Lol.
Alright now.
But can you get it refine and done better?
Art, Graphics & Video / Who Can Finish UP This Model by Capslock01: 10:52pm On Oct 05, 2021
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

Art, Graphics & Video / . by Capslock01: 11:53am On Sep 30, 2021
.
Programming / Re: Urgent!!! Pls Help A Frustrated Friend!! by Capslock01: 4:43am On Sep 21, 2021
Bigman101:
Pls a friend need suggestions from you all ( wonderful people)
i think this is the right place to bring this up..

I have a close friend and He wants to start learning web design and programming, but the problem is this.. How to stay motivated and also how to stay awake at nights in order to learn..(pls note he wants to learn through YouTube' videos and ebooks on programming).. this my friend says that at times when he start (11pm) b4 you know it he is sleeping ,waking up by 4 or 5 am...Despite taking energy drinks like ( fearless or predator) he will still sleep... this got him frustrated and I can't advise him. so I said to him that I'll bring it up here, coz definitely there will a solution here!!!

Pls moderators help push this to front page for wider views and response
mukina2

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!

3 Likes

Programming / Re: Country Time Display In Javascript by Capslock01: 10:50am On Sep 19, 2021
.
Programming / Re: Javascript Problem by Capslock01: 11:26pm On Sep 11, 2021
Brightale:
apart from the missing curly bracket, there should be space after the second return too

With or without space, it'll still run.
The issue with his code was not having curly bracket set.
Programming / Re: Help, Javascript Problem, (pictures Attached) (fixed) by Capslock01: 11:15pm On Sep 11, 2021
Think4Myself:
Please Help me find out why this simple interest program is not working well,
It will work and calculate the simple interest only for it to display the answer(simple interest) for just a milliseconds or thereabout

Picture below

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.
Programming / Re: What Should I Start From Between XHTML And HTML5 by Capslock01: 9:42pm On Aug 30, 2021
Start like this! HTML5
CSS
JavaScript.

They're more like same thing but HTML5 is less strict than XHTML.
Exclude XHTML abeg
Programming / Re: Help Me With This Javascript Problem by Capslock01: 11:09am On Aug 18, 2021
africanman85:

Your (if and else augument) did not execute .

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:

//Q1
const calcAvg = function (input1, input2, input3){
return (input1 + input2 + input3)/3;
}

//Q2 ---DATA 1 && DATA 2
const avgDolphins = calcAvg(44, 23, 71); //Test for Data 1 --- "Value is 46"
const avgKoalas = calcAvg(65, 54, 49); //Test for Data 2 --- "Value is 56"

const avgDolphins1 = calcAvg(85, 54, 41); //Test for Data 1 --- "Value is 60"
const avgKoalas1 = calcAvg(23, 34, 27); //Test for Data 2 --- "Value is 28"

console.log('Dolphins Average is ---> ' + avgDolphins)
console.log('Koalas Average is ---> '+ avgKoalas)

console.log('Dolphins Average is ---> ' + avgDolphins1)
console.log('Koalas Average is ---> '+ avgKoalas1)

//Q3 && Q5 --- IF statement covers Q5 ---
function checkWinner (avgDolphins1, avgKoalas1) {
if (avgDolphins1 >= 2*avgKoalas1) {
console.log (`Delphins win (${avgDolphins1} vs ${avgKoalas1})`);
} else if (avgKoalas1 >= 2*avgDolphins1) {
console.log (`Koalas win (${avgDolphins1} vs ${avgKoalas1})`);
} else {
console.log('No team win')
}
}
//Q4 && Q5
checkWinner(46, 56) //Test for Data 1 Average
checkWinner(60, 28) //Test for Data 1 Average


You can post more questions/challenge
Programming / Re: Help Me With This Javascript Problem by Capslock01: 12:47am On Aug 18, 2021
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.

2 Likes

Programming / Re: Help Urgently Needed On My Command Prompt by Capslock01: 2:26pm On Aug 14, 2021
flex04:
I have updated PIP, python, virtualenv but this error keeps coming... If you have an idea how to go about it, kindly help


cc: lalasticlala

Go to the folder and run CMD .exe from there
Programming / Re: One JavaScript Study Partner Needed (online or IB) by Capslock01: 3:49pm On Jul 24, 2021
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.

1 Like

(1) (2) (3) (4) (5) (6) (7) (8) (9) (10) (of 12 pages)

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 42
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.