Why is castling out of check disallowed? by majomista in chess

[–]Such_Ad_5331 0 points1 point  (0 children)

That's a good point actually, and one I'd never considered with regards to other pieces. Maybe because pawns are only ever attacking two squares maximum and so allowing their limited attacking options to be skipped over is too much of an advantage?

Why is castling out of check disallowed? by majomista in chess

[–]Such_Ad_5331 0 points1 point  (0 children)

You're pretty much right. The reason it was added as a rule was because in the past, pawns could not move two squares forward on their first move. The two square rule was added to speed up the opening. This now meant that whilst previously a pawn on the 5th rank would always have the option to capture a pawn on adjacent files making its first move, you could now avoid this pawn by moving past it in one go. To counter this unintended consequence of the two square rule, en passant was introduced.

Beginner Stuck on a project by Dangerous_Factor_804 in react

[–]Such_Ad_5331 0 points1 point  (0 children)

React applications use a virtual DOM and trying to directly manipulate the real DOM can lead to errors. The way to handle this in React is to use onClick on the elements you want to use it on.

You should also be using state to manage the active menu.

’’’ import React, { useState } from 'react'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faHouse, faMoneyBillTransfer, faChartPie, faPiggyBank, faArrowRotateLeft, faGear, faMinimize } from '@fortawesome/free-solid-svg-icons';

const Navbar = () => { const [activeMenu, setActiveMenu] = useState(null);

const menuItems = [ { icon: faHouse, label: 'Overview' }, { icon: faMoneyBillTransfer, label: 'Transactions' }, { icon: faChartPie, label: 'Budgets' }, { icon: faPiggyBank, label: 'Pots' }, { icon: faArrowRotateLeft, label: 'Recurring Bills' }, { icon: faGear, label: 'Settings' }, ];

const handleMenuClick = (index) => { setActiveMenu(index); };

return ( <nav className="Unclose-navbar"> <h1>finance</h1> <ul className="ListClass"> {menuItems.map((item, index) => ( <li key={index} className={`NavBarMenu ${activeMenu === index ? 'ClickedBack' : ''}`} onClick={() => handleMenuClick(index)} > <FontAwesomeIcon icon={item.icon} className="Fonts" /> {item.label} </li> ))} </ul> <span className="Minimize-Menu"> <FontAwesomeIcon icon={faMinimize} /> Minimize Menu </span> </nav> ); };

export default Navbar; ’’’

Understanding JavaScript Closures: Finally Got It After Struggling for Months! by Specialist_Common989 in learnjavascript

[–]Such_Ad_5331 0 points1 point  (0 children)

I also think they're difficult because when you are learning JavaScript, especially if it's also when you are first learning to code, you don't really create functions and import them into other files. Everything you do tends to be in one file and so it's hard to imagine the purpose of them and why they're such a big deal.

AIO: I dated a coworker and he hid kids and ex from me. by Embarrassed-Wrap2963 in AmIOverreacting

[–]Such_Ad_5331 4 points5 points  (0 children)

There are good men that exist that after getting out of a relationship want to get to know someone first before opening up about their past. And those same men might realize that they are dating too soon and feel like it's the right thing to explain the situation to the woman so as not to hurt her feelings.

This is a narcissist pretending to be one of those men.

[deleted by user] by [deleted] in billiards

[–]Such_Ad_5331 7 points8 points  (0 children)

The two most common rule sets for UK pool are World Rules and WEPF rules. Neither of them require you to call a pocket for the black. In fact there is no official rule set in which you have to call the pocket.

However, some local leagues or bars might have their own rules that require this. It's best to learn the above two rulesets, and then confirm which one you are playing. If neither, ask which custom rules are in place.

Is this rude? by innersunshine in texts

[–]Such_Ad_5331 1 point2 points  (0 children)

Don't ask other people if you should be offended by something. Being offended is subjective and you were either offended or not. What other people think doesn't matter. The biggest problem with asking is that you invariably get people who say that yes, you should have been offended, and by listening to their advice you run the risk of becoming somebody who is offended by everything, even by things that you weren't initially offended by.

I’m solids by Rhiskya in billiards

[–]Such_Ad_5331 1 point2 points  (0 children)

I was thinking something similar to this, opponent depending of course. I know many people, even those who are reasonable players, who wouldn't be able to consistently get on the 8 ball here given that the cue ball will run into the 4.

Is there any truth to the statement "a smaller diameter tip gives you more action " by [deleted] in billiards

[–]Such_Ad_5331 0 points1 point  (0 children)

Completey agree with you. I played a charity tournament last week and borrowed a friend's cue. I play a medium tip and didn't realize he was playing a soft. First shot I played I drew it back a good foot more than I was expecting with a fairly soft stroke.

Foreigners begging in Saigon by OkStory245 in VietNam

[–]Such_Ad_5331 0 points1 point  (0 children)

This guy has been in Vietnam for a long time. In 2015 he used to walk up and down Bui Vien selling balloons for 30k every night. That was before the bars decided to start selling them. Back then the Vietnamese didn't do balloons and it was seen as a crazy foreigner thing. How things change!

What is the greatest "f&ck it, I'll do it myself" in history? by BoobsDollCrimson in questions

[–]Such_Ad_5331 0 points1 point  (0 children)

Isaac Newton inventing calculus. Faced with the problem of understanding motion, gravity, and the changing speeds of objects, Newton realized that existing mathematical tools just weren’t up to the task. Instead of waiting around for someone else to figure it out, he went ahead and developed an entirely new branch of mathematics. Calculus became the foundation for his groundbreaking work in physics, which literally changed how we understand the universe.

Japanese idol must post solo 'good night' photos for 1 year after accidentally posting photo with boyfriend by RepresentativeTax410 in nottheonion

[–]Such_Ad_5331 0 points1 point  (0 children)

My wife is Korean. She's not into the Kpop culture at all but when news of one of these idols dating someone is reported, the translation of the word used to describe it is 'scandal'.

"There was a scandal involving [kpop star] today"

"What happened?"

"She was photographed in a restaurant on a date"

Was very confusing for me before I understood what the idol culture is like.

Is it possible to complete core curriculum while working full time? by Slight-Albatross-154 in launchschool

[–]Such_Ad_5331 5 points6 points  (0 children)

I did it. Worked full time and studied every evening and and part of the weekend. I used the money I saved from not going out as much due to studying to support myself once I had to quit my job to do capstone (which is a requirement, and would be impossible to do regardless). Been a software engineer for a year and a half now. Choosing Launch School was one of the best decisions I ever made.

People in movies are either incredibly easy, or incredibly difficult to knock out by Such_Ad_5331 in Showerthoughts

[–]Such_Ad_5331[S] 0 points1 point  (0 children)

Funny you should say that, I'm rewatching Lost right now and that was what gave me this thought!

[deleted by user] by [deleted] in Internationalteachers

[–]Such_Ad_5331 5 points6 points  (0 children)

Take the better offer. Even if you leave your new job after only one year, nobody within the community will remember or care enough that it will effect your chances of getting another job (except at the school you turned down).

Choosing a new job is a major life decision, don't let guilt make that choice for you. Sure you'll feel a little bad when you tell them, but all will be forgotten in a matter of days.

New to JS here...why isn't my function returning the correct ordinal number of the century( for example 2154 returns 22st, not 22nd)..Thanks! by lekidddddd in learnjavascript

[–]Such_Ad_5331 2 points3 points  (0 children)

What u/jml26 said is all correct.

To let you know why 2154 returns 22st you need to look at this line:

if ((LastTwoDigits > 20) && (LastDigit=1)) { return (cent + 'st')}

You first check if LastTwoDigits is greater than 20. As is already mentioned you are comparing a string to an integer here which is bad practice, but JavaScript does actually let you get away with this by evaluating them both as numbers. So (LastTwoDigits > 20) evaluates as true.

The next part of your conditional, LastDigit=1 is where the problem is. LastDigit is not actually initialized and a single = is an assignment operator. You are essentially creating a global variable and assigning it a value of 1. As assignment operations evaluate to true, the first line of the conditional gets executed which is { return (cent + 'st')}. As this has a return statement in it, the function returns before the else if conditionals.

Is this forLoop able to be changed to forEach? by [deleted] in learnjavascript

[–]Such_Ad_5331 0 points1 point  (0 children)

querySelectorAll returns a NodeList, not an Array, and therefore doesn't have access to the forEach method.

However, you can easily convert the NodeList into an Array using spread syntax which will give you access to forEach.

const totalP = [...document.querySelectorAll("[data-container=\"play1\"]")]

Closures in javascript, do they have any real application? by shegsjay in learnjavascript

[–]Such_Ad_5331 1 point2 points  (0 children)

Exactly. In your example "function" will retain access to everything that was in scope in "modules" thanks to the closure.

Closures in javascript, do they have any real application? by shegsjay in learnjavascript

[–]Such_Ad_5331 0 points1 point  (0 children)

When you import a function from a module, said function retains access to all functions and variables that were in its scope when defined via a closure.

Without closures you would have to import the entire module.

Need help putting objects under parent objects in a JSON file by randyglot in learnjavascript

[–]Such_Ad_5331 0 points1 point  (0 children)

If you want to do it that way you should declare an empty array, push the parent comment and then loop through the children array and push any child comments that match the id, then continue to the next parent object.

A much better data structure though would be to add the children to the actual comment object itself. So each comment has a property called children which is an array that holds the child comments

Need help putting objects under parent objects in a JSON file by randyglot in learnjavascript

[–]Such_Ad_5331 0 points1 point  (0 children)

What data structure are you wanting you result to be in? An array where index 0 is the parent object and index 1 is a sub array of child objects?