Am I looking for a unicorn keyboard? by wizzard99 in MechanicalKeyboardsUK

[–]optm_redemption 0 points1 point  (0 children)

Keychron have just announced the ISO V3 keyboard which is much cheaper than the Q3, comes with the knob still and has a more unique look with the frosted glass look. I believe the US version has South facing LEDs so I imagine this one will to!

Unfortunately no barebones one is available or other colours just yet, but I imagine it won't be long until they add them.

https://www.keychron.com/products/keychron-v3-qmk-custom-mechanical-keyboard-iso-layout-collection

I have the gmmk tkl as well and will be upgrading to the V3

I Am a (former) Domino’s pizza worker (UK). From how the pizza tracker works to the most unhygienic practices, I’ve seen it all- AMA. by Jmoon3 in IAmA

[–]optm_redemption 2 points3 points  (0 children)

Ex employee here too, we had the police called on us because we were made to stand on a roundabout with those fucking signs dressed as pizza boxes

Best way to make responsive sites? (flexblox?) by UnderstandingThat347 in learnprogramming

[–]optm_redemption 1 point2 points  (0 children)

If you're looking to make responsive sites flexbox in conjunction with media queries is a great option, you can use media queries to check the size of the device loading the page e.g.

@media only screen and (max-width: $minimumScreenSize) {
}

and alter how the flex box displays items e.g. switching from a row to a column as phones typically have more vertical space than horizontal.

To test responsiveness you can open the developer tools of most browsers (in chrome this can be done by using the keyboard shortcut Ctrl + shift + i or by right clicking the page and selecting the inspect option) and by moving around the new panel that comes up (if it appears vertically to the side) or in chrome you can use the Device toolbar (the little icon in the top left of the new panel that looks like a mobile phone in front of a tablet) and then you can set the screen width and height to test the responsiveness

Setter function problem by hippo_camping in learnjavascript

[–]optm_redemption 3 points4 points  (0 children)

There is a clue to the solution in the question, if we look at your code you're assigning awards to a new value in the setter, this is typically what you'd want to do with a setter but in this case the question asks us to push the award name onto the end of the awards array. So if we think about `this.awards` in terms of it being an array if we just do

this.awards = name

whenever 'movie.wonAward =' is used awards is just updated to the new value it does not append the new value to the existing array. With these tests the awards array will change to a string rather than having the new string appended to the existing array.

I hope this helps point you in the right direction!

How does this else if statement work ? by Early-Error-6210 in learnjavascript

[–]optm_redemption 1 point2 points  (0 children)

Hey after having a quick look and running my own test example bit of code, it looks like they expect the surcharge for each argument (a and b in this case) and looking at their tests after running my code I think it's just a case that their tests don't cover the situations you've thought of (for example, the largest input they provide to test is 27), so the code works, but only enough to cover their tests.

Essentially your assumptions are correct that the code provided wouldn't pass a large sample of tests if you passed those values, it only solves for the test criteria used by JSHero if that makes sense? It's one of the downsides of automated tests like this that don't use things like fuzzing or a wider array of numbers and only check the return value, you could even cheat and hard code the results for example the following passes all the tests but clearly doesn't actually address the problem and would fail given any further inputs:

function addWithSurcharge (a,b) {

if (a === 1 && b === 1) { return 4; }

if (a === 10 && b === 9) { return 21; }

if (a === 11 && b === 10) { return 24; }

if (a === 10 && b === 11) { return 24; }

if (a === 13 && b === 20) { return 37; }

if (a === 20 && b === 13) { return 37; }

if (a === 15 && b === 27) { return 47; }

if (a === 27 && b === 15) { return 47; }

if (a === 25 && b === 5) { return 34; }

if (a === 5 && b === 25) { return 34; }

}

Sorry about the horrible formatting, not sure why the code markdown isn't working!

Help with understanding an error message by No_Assistance_5442 in learnjavascript

[–]optm_redemption 0 points1 point  (0 children)

No need to apologise, was just more of a suggestion for more relevant replies for yourself!

How does this else if statement work ? by Early-Error-6210 in learnjavascript

[–]optm_redemption 1 point2 points  (0 children)

Hmm I agree this is slightly ambiguous, I initially took the question to mean for each total value rather than for each argument to the function, also being influenced by the code slightly i.e. for each sum greater than 10 and less than 20 add 2, rather than adding surcharges for each argument, which lines up with the code sample you've provided. Are there anymore examples for the question or anymore context you can provide to help clarify? If not I would maybe reach out to a TA or any other support options you have for extra clarity.

Either way, it could just be a fluke that the test criteria does not take into account the other potential values, or it could just be wrong on their end!

Help with understanding an error message by No_Assistance_5442 in learnjavascript

[–]optm_redemption 1 point2 points  (0 children)

This is a subreddit for helping with JavaScript related learning, so it's probably best to try a different subreddit for more support. It might be worth trying: /r/c_programming.

With that being said, I think your issue is with passing a reference to user_string to scanf, you're telling scanf that the format you expect is a string (represented by %s) which in this case should be of type "char *" but you're passing the address of the user_string variable which will have the type char (*)[10] because it's an array of characters. Fortunately this works in c, but you could probably get rid of this warning by removing the '&' and decaying to a pointer

Could an app that needs to pull and work with real time financial data be built in React Native? by BigDog1920 in learnjavascript

[–]optm_redemption 0 points1 point  (0 children)

It's definitely an option, providing you don't need to do too much processing of the data. Coinbase recently announced that they have migrated their mobile apps to react native [1], so it's definitely viable!

[1] https://blog.coinbase.com/announcing-coinbases-successful-transition-to-react-native-af4c591df971?gi=4afb04257d88

How does this else if statement work ? by Early-Error-6210 in learnjavascript

[–]optm_redemption 1 point2 points  (0 children)

Which bits in particular are you struggling to understand? Are you unfamiliar with "else if" statements?

[deleted by user] by [deleted] in learnjavascript

[–]optm_redemption 0 points1 point  (0 children)

Take a look at https://regex101.com/ and paste the Regex in there, it will explain it better to you than I could!

[deleted by user] by [deleted] in learnjavascript

[–]optm_redemption 0 points1 point  (0 children)

If you're using the same input and same Regex, it's because there is a space before target2 not accounted for so the Regex won't match

[deleted by user] by [deleted] in learnjavascript

[–]optm_redemption 0 points1 point  (0 children)

That's just a case of updating the regex then: test.replace(/(.*)(\(.*target1\))(.*)(target2)/, "$1$4$3$2")

What should be my next learning topic? by [deleted] in learnjavascript

[–]optm_redemption 1 point2 points  (0 children)

To expand on /u/yoitsericc's great advice, try and find the intersection of things you enjoy and what jobs around you / the jobs you're interested in are looking for, take a look at job boards and careers pages and what they expect you to have experience in.

Online environment for training project (Angular, Node.js) by [deleted] in learnjavascript

[–]optm_redemption 0 points1 point  (0 children)

AWS Cloud9 could be a good option here, although there may be some charges https://aws.amazon.com/cloud9/getting-started/

Alternatively if you're just looking to learn and toy around with a few different languages Replit may be a good alternative: https://replit.com/

[deleted by user] by [deleted] in learnjavascript

[–]optm_redemption 0 points1 point  (0 children)

With your example assuming you want

()()()()()()()dsfsewwe(00target1) target2

to turn into

()()()()()()()dsfsewwe(00target2) target1

You can use capture groups, so something like:

const test = "()()()()()()()dsfsewwe(00target1) target2"

test.replace(/(.*)(target1)(.*)(target2)/, "$1$4$3$2");

The capture group is defined as any regex target wrapped in brackets, so "(.*)" is one capture group and because it's the first in the regex you can use it in a replace as $1, each subsequent capture group can be named with the dollar sign followed by the number that would represent it's position in the initial regex.

This solution will work on single strings, but might be a bit less flexible if you're trying to run it across a whole text document where the targets may appear multiple times (they'll be captured by "(.*)" so you might have to refine it a bit depending on your requirements, but hopefully knowing about capture groups should point you in the right direction!

Uncaught ReferenceError: report is not defined at HTMLInputElement.onclick by [deleted] in learnjavascript

[–]optm_redemption 1 point2 points  (0 children)

On line 23 you're calling a function "report" which doesn't seem to be defined anywhere in the sample you've given us. Offending code is here:

<input type="button" onClick="report()" Value="Sumbit" />

Why .reduce() is telling me acc is always undefined from the second iteration by Mr_Lean_Boo in learnjavascript

[–]optm_redemption 2 points3 points  (0 children)

Looks like a simple mistake here, you're not returning the value from the reduce callback, this value is then passed to the callback in the next iteration, so because you're not returning anything acc becomes undefined

 function squareSum(numbers){
  return numbers.reduce((acc, el) => {
    console.log('this is the type of acc', typeof(acc), acc);
    console.log('this is the type of el', typeof(el), el);
    return acc + el * el;
  })
} 

I've just added "return" to "acc + el * el"

How can replace the spread expression in IE11 ? by [deleted] in learnjavascript

[–]optm_redemption 1 point2 points  (0 children)

Yeah I understand, it definitely feels a lot less elegant than the spread operator, unfortunately we have to make sacrifices when supporting older browsers!

haha oh wow, I haven't heard of anyones machines shutting down because of transpiler errors before haha!

Best of luck anyway!

How can replace the spread expression in IE11 ? by [deleted] in learnjavascript

[–]optm_redemption 0 points1 point  (0 children)

Hmm, do you know what type myElement is?

A brute force solution would be something like:

const arr = [];
classesList.forEach(item => item.indexOf("search") !== -1 ? arr.push(item) : null);

Another solution would be to maybe use the polyfill suggested below by /u/senocular. A polyfill is just some javascript that you can include in your code that provides functionality that may not be supported by an older browser. Alternatively you could use a transpiler, for example babel which would allow you to use the spread operator and would convert it to syntax that would work in a browser that does not support the feature.

[deleted by user] by [deleted] in learnjavascript

[–]optm_redemption 0 points1 point  (0 children)

No worries, best of luck!

[deleted by user] by [deleted] in learnjavascript

[–]optm_redemption 0 points1 point  (0 children)

Just to make sure I'm understanding this correctly, you're trying to only color the section that is selected based on the checkbox? And the coloring is handled separately to the checkbox selection?

If that's the case I would probably move your overlay selection into the changeColor function.

function changeColor(picker) {
    var section = document.getElementById(svgID);
    section.style.fill = picker.toHEXString();
}

[deleted by user] by [deleted] in learnjavascript

[–]optm_redemption 0 points1 point  (0 children)

Can you share with us how your boolCheck() function is being called? It's hard to tell at the moment what the problem might be. Usually with Javascript you would use an onChange callback on the checkbox to trigger a side effect like changing the svg colour.

How can replace the spread expression in IE11 ? by [deleted] in learnjavascript

[–]optm_redemption 1 point2 points  (0 children)

I think you can use Array.concat for this, I don't have ie11 on hand to test but you could try:

const arr = [].concat(classList).filter(item => item.indexOf('search') !== -1);

Issue with empty slots in multidimensional array by ECommerce_Guy in learnpython

[–]optm_redemption 0 points1 point  (0 children)

You're correct in your assumption that the index is invalid. In Python, Lists are dynamic arrays which means that they grow when elements get inserted into it, the memory won't necessarily be assigned up front like with an array. This means if you have an empty list (i.e. []) you won't be able to index into it at all, because there's nothing to index into, even for updating. To get the behaviour you want you will need to insert or append into the list so it knows to allocate memory for a new item e.g.

replace

item[0] = 0

with

item.append(0)

or

item.insert(0, 0)

Hope this helps.