₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,328,973 members, 8,438,216 topics. Date: Friday, 03 July 2026 at 06:59 AM

Toggle theme

What Would Be The Output Of This JS Code (pics) - Programming (2) - Nairaland

Nairaland ForumScience/TechnologyProgrammingWhat Would Be The Output Of This JS Code (pics) (1888 Views)

1 2 Reply (Go Down)

Re: What Would Be The Output Of This JS Code (pics) by tensazangetsu20(m): 8:57am On Jul 04, 2022
airsaylongcome:
This is news to me! I really need to get to speed with all the new additions in these programming languages
Actually this isn't valid in java even with the inclusion of car in java 10. You have just equals and == but apex has it. It's pretty much an extension of java and used in Salesforce development.

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_expressions_operators_understanding.htm


I always thought java had that as I have used that a lot in Apex which is also strongly typed.
Re: What Would Be The Output Of This JS Code (pics) by jbreezy: 9:14am On Jul 04, 2022
JoyousFurnitire:
I was only supporting your point though so the op can see it's impossible to skip the basics undecided
ooh my bad..I was half-sleepy
Re: What Would Be The Output Of This JS Code (pics) by remi1444: 9:49am On Jul 04, 2022
airsaylongcome:
This is news to me! I really need to get to speed with all the new additions in these programming languages
good morning boss cool
Re: What Would Be The Output Of This JS Code (pics) by Deicide: 10:24am On Jul 04, 2022
tensazangetsu20:
Java has it too and it's strongly typed.
Since when did java have triple equal to?

Oh I see you corrected yourself up there grin
Re: What Would Be The Output Of This JS Code (pics) by excanny: 10:32am On Jul 04, 2022
sixpathsofpain:
and please bro, what's the use of the first if and return statement? because I don't see any need for them
The first “if” is a validation of the input so a user doesn’t enter 1 as a value.
Re: What Would Be The Output Of This JS Code (pics) by airsaylongcome: 11:50am On Jul 04, 2022
remi1444:
good morning boss cool
No worry. I go holla you as soon as I reach GIG
Re: What Would Be The Output Of This JS Code (pics) by airsaylongcome: 11:56am On Jul 04, 2022
excanny:
The first “if” is a validation of the input so a user doesn’t enter 1 as a value.
Not correct. It's not validating the user Input. It's checking for the "Base Case" for the factorial function. If the user enters 1 as input, 1!=1 and the if will correctly return 1 as the factorial of 1. This function requires some knowledge of the factorial function to understand what it is doing. Basically n! is equal to n*(n-1)!. That is 5! for example is equal to 5*4!. 5!=5*4*3*2*1 and 4!=4*3*2*1 so 5! Is 5 times 4!
Re: What Would Be The Output Of This JS Code (pics) by Nobody: 12:22pm On Jul 04, 2022
airsaylongcome:
Not correct. It's not validating the user Input. It's checking for the "Base Case" for the factorial function. If the user enters 1 as input, 1!=1 and the if will correctly return 1 as the factorial of 1. This function requires some knowledge of the factorial function to understand what it is doing. Basically n! is equal to n*(n-1)!. That is 5! for example is equal to 5*4!. 5!=5*4*3*2*1 and 4!=4*3*2*1 so 5! Is 5 times 4!
Lols...it's actually not this complicated jeez.
This should be the most complicated answer to the most basic question ever.

It shows you yourself don't understand what's happening there
cheesy
Re: What Would Be The Output Of This JS Code (pics) by JoyousFurnitire(m): 1:28pm On Jul 04, 2022
sixpathsofpain:
bro thanks for your explanation. It really helped me alot. I'm beginning to rap my head around recursions little by little but I know this I going to take time mehn but I know I wouldn't give up no matter how long it takes, I can't just stop going back to try and figure it out grin
Please I need your advice on something. I feel you're one of the few reasonable and matured one's on this thread..
Please the reason I wanted to learn JAVASCRIPT in the first place was because I want to become a full-stack web developer. And I just jumped in JavaScript straight on. after sometime and a few research, I found out I needed to learn HTML and CSS first before JavaScript and then react (I don't know what any of them does cause I'm a noob smiley ) so now I'm planning on quitting JAVASCRIPT for now, to go focus on HTML first then CSS before continuing JAVASCRIPT and then what ever should follow (for me to become full-stack) would you advise me to quit JavaScript now and go focus on those (HTML and CSS) or I can continue with JAVASCRIPT before HTML and CSS?

And please just help me give an outline of how my learning path should be to become full-stack ( because I don't like starting what I don't Finnish smiley )
Thanks

@tensazangetsu20
please you too can help me contribute
You can actually learn HTML5 and JavaScript side by side.

You just have to create a time table. Say 2 hrs for each paper day. It's possible. Just don't overthink what you don't get ask questions.

If you know you can't take all together then take it one by one from html, css and JS.

For CSS focus on layout with flex-box or CSS grid (refer to this post when you get there).

Learn CSS very well before moving to other libraries.

Take it easy on yourself.

For outline, visit freecodecamp(dot)org

PS: There're many great peeps on here no mind that Igboman him just to catch cruise cheesy

Re: What Would Be The Output Of This JS Code (pics) by airsaylongcome: 1:46pm On Jul 04, 2022
GREATIGBOMAN:
Lols...it's actually not this complicated jeez.
This should be the most complicated answer to the most basic question ever.

It shows you yourself don't understand what's happening there
cheesy
Very wordy, yes. But it's a basic straight forward recursive solution of factorial function. Calls itself each time reducing the input to the function by one. Until it gets to the vase case of 1 and then like a stack, "pops" every previous call. Na textbook stuff. Maybe my previous explanation was too convoluted, but this function is too basic for me not to know
Re: What Would Be The Output Of This JS Code (pics) by Karleb(m): 2:15pm On Jul 04, 2022
airsaylongcome:
Very wordy, yes. But it's a basic straight forward recursive solution of factorial function. Calls itself each time reducing the input to the function by one. Until it gets to the vase case of 1 and then like a stack, "pops" every previous call. Na textbook stuff. Maybe my previous explanation was too convoluted, but this function is too basic for me not to know
It's basically the first thing everyone learns when learning recursion.
Re: What Would Be The Output Of This JS Code (pics) by sixpathsofpain(op): 2:40pm On Jul 04, 2022
JoyousFurnitire:
You can actually learn HTML5 and JavaScript side by side.

You just have to create a time table. Say 2 hrs for each paper day. It's possible. Just don't overthink what you don't get ask questions.

If you know you can't take all together then take it one by one from html, css and JS.

For CSS focus on layout with flex-box or CSS grid (refer to this post when you get there).

Learn CSS very well before moving to other libraries.

Take it easy on yourself.

For outline, visit freecodecamp(dot)org

PS: There're many great peeps on here no mind that Igboman him just to catch cruise cheesy
Thanks alot bro. Really appreciate. Just one question grin others libraries like ? PHP ? Or what
Re: What Would Be The Output Of This JS Code (pics) by JoyousFurnitire(m): 2:45pm On Jul 04, 2022
sixpathsofpain:
Thanks alot bro. Really appreciate. Just one question grin others libraries like ? PHP ? Or what
Other CSS libraries like Bootstrap.

Also same with JavaScript, master and learn the basics very well before jumping to libraries like React.

PHP is a programming language like JavaScript.
Re: What Would Be The Output Of This JS Code (pics) by sixpathsofpain(op): 3:03pm On Jul 04, 2022
JoyousFurnitire:
Other CSS libraries like Bootstrap.

Also same with JavaScript, master and learn the basics very well before jumping to libraries like React.

PHP is a programming language like JavaScript.
Bro may God almighty continue to bless you for people like us. Please just a few more question I'd like to ask( lastest, I promise grin )

1.) Do you suggest I change OS from WINDOWS to LINUX ( to prevent unnecessary crashing since Linux is more light weight)
2.) Should I create a github account or repo now or when I'm ready to start building projects
3.) Like how long would it take me to become a junior full-stack developer if I studied seriously for 5 hours minimum a day ? Im thinking maybe after 1year and five months..
Re: What Would Be The Output Of This JS Code (pics) by JoyousFurnitire(m): 3:52pm On Jul 04, 2022
sixpathsofpain:
Bro may God almighty continue to bless you for people like us. Please just a few more question I'd like to ask( lastest, I promise grin )

1.) Do you suggest I change OS from WINDOWS to LINUX ( to prevent unnecessary crashing since Linux is more light weight)
2.) Should I create a github account or repo now or when I'm ready to start building projects
3.) Like how long would it take me to become a junior full-stack developer if I studied seriously for 5 hours minimum a day ? Im thinking maybe after 1year and five months..
1) Windows is fine

2) Yes learn git and GitHub early

3) It depends on you. Set your timeframe.
Re: What Would Be The Output Of This JS Code (pics) by namikaze: 4:31pm On Jul 04, 2022
jbreezy:
Op doesn't even have a solid knowledge of function yet.
Oh, I see. Op should do due diligence to the basics first.
Re: What Would Be The Output Of This JS Code (pics) by Nine2ten: 7:58pm On Jul 04, 2022
6

Recursive
3 X 2 X 1
Re: What Would Be The Output Of This JS Code (pics) by Lasmarr: 10:11pm On Jul 04, 2022
sixpathsofpain:
honestly bro please if you can just help me do a little explanation, I'd really appreciate because function declaration and recursions are confusing me seriously. I don't even know where you got 2 from to multiply it by 3.
that n is 3 and n - 1 = 2
Re: What Would Be The Output Of This JS Code (pics) by captainbangz: 7:36am On Jul 05, 2022
sixpathsofpain:
and please bro, what's the use of the first if and return statement? because I don't see any need for them
if the first 'if' condition isn't there, ftl(1) will return 0. whereas, even the factorial of zero is 1. That if condition alone doesn't even make that solution correct, because ftl(0) will return zero instead of 1.
Re: What Would Be The Output Of This JS Code (pics) by airsaylongcome: 12:00pm On Jul 06, 2022
remi1444:
good morning boss cool
Your Bible verse shock me. Sorry abeg. I'm doing a 16 hour rotation now so I no dey sleep well again. Unfailingly sending tomorrow. No vex abeg.

Re: What Would Be The Output Of This JS Code (pics) by remi1444: 4:02pm On Jul 06, 2022
airsaylongcome:
Your Bible verse shock me. Sorry abeg. I'm doing a 16 hour rotation now so I no dey sleep well again. Unfailingly sending tomorrow. No vex abeg.
grin grin grin na me dey beg so I need dey persistent and “worrisome”. Thank you boss for previous and future. I appreciate it.
Re: What Would Be The Output Of This JS Code (pics) by The5DME(m): 4:17pm On Jul 06, 2022
remi1444:
grin grin grin na me dey beg so I need dey persistent and “worrisome”. Thank you boss for previous and future. I appreciate it.
Thank you boss too, for the future cool
1 2 Reply

As A Programmer, What Will Be The Output Of This Code?I Asked Chatgpt To Write A Poem About Nairaland. Here's The OutputWrote My First JS Code On VS Code.... Lol (pics)234

Tech Team Needed....Who Knows Phone ProgrammingCcan I Learn Java In A Month? Somebody Answer Me !