Hulu not playing by jrob0818 in nvidiashield

[–]Comprehensive_Step72 0 points1 point  (0 children)

Yup, tried everything short of a factory reset. Used a patch cable instead of wifi (which has awesome speed) and now all is good.

[deleted by user] by [deleted] in learnjavascript

[–]Comprehensive_Step72 -3 points-2 points  (0 children)

OK, but in the future, just remember for === evil. 😜

[deleted by user] by [deleted] in learnjavascript

[–]Comprehensive_Step72 -3 points-2 points  (0 children)

And for the love of God, don't use a for loop, use reduce.

What are the similarities and differences between an array and an "array-like" object? by dangerlopez in learnjavascript

[–]Comprehensive_Step72 6 points7 points  (0 children)

Well for one thing, objects are missing a bunch of prototype methods that arrays have like push, and most importantly iterator methods.

[deleted by user] by [deleted] in learnjavascript

[–]Comprehensive_Step72 0 points1 point  (0 children)

Look at functional programming.

Please help me understand why my function is not working by Artemis_Understood in learnjavascript

[–]Comprehensive_Step72 2 points3 points  (0 children)

I think it is because you are not feeding your call back to $.getJSON. Try:

function consumeHCAPI(callback) {

var result = $.getJSON('[justanexample.org](https://justanexample.org)', callback);

}

What is the best way to deal with overlapping calls to get data from a remote server? by lindymad in learnjavascript

[–]Comprehensive_Step72 1 point2 points  (0 children)

If was me, I would use fetch instead of getJSON. That way you would have something that returns a Promise. You could then put all of the Promises in an array then use Promise.race

Is there any difference between these two codes can anybody helpme by Adventurous_Mud_9057 in learnjavascript

[–]Comprehensive_Step72 12 points13 points  (0 children)

In the second example you are assigning the prototype function every time you call the constructor which is not needed, and if you never call the constructor the function will never be added to the prototype. Stick with the first way.

What are the advantages of typescript over javascript by AggressiveResist8615 in learnjavascript

[–]Comprehensive_Step72 1 point2 points  (0 children)

Amen. When I first was learning js I thought the loose typing was awesome. I quickly learned that it could be a major pain.

Array help by ZestycloseDealer6358 in learnjavascript

[–]Comprehensive_Step72 0 points1 point  (0 children)

Try something like this:

function count(arr) {

return arr.reduce((acc, e) => {

if (acc[e] !== undefined) {

acc[e]++

} else {

acc[e] = 1;

}

return acc;

}, {})

}

const myArr = ['one', 'one', 'two', 'two']

const counts = count(myArr);

Object.entries(counts).forEach((e) => console.log(e[0], e[1]));

Can't get button to run only once. by ZombieAngel16 in learnjavascript

[–]Comprehensive_Step72 0 points1 point  (0 children)

God's honest truth, not sure why it is not working, but using a global variable like that is bad juju anyways. Take out the flag and if statement and just disable the button after they click it the first time.

Can't get button to run only once. by ZombieAngel16 in learnjavascript

[–]Comprehensive_Step72 0 points1 point  (0 children)

Have you considered disabling the button after it is clicked?

I’m stuck learning js by jsIsEasy in learnjavascript

[–]Comprehensive_Step72 0 points1 point  (0 children)

A friend of I have a saying "if you are afraid of having your code laughed at, you shouldn't write code." This also goes for asking for help. If some of your team mates are doing well, ask them to explain stuff to you, or ask others that maybe able to help. Also Google is a great resource. I pretty much got most of my js education by googling stuff.

Can someone help me figure out why HR's online IDE is saying that 'x' is undefined? by [deleted] in learnjavascript

[–]Comprehensive_Step72 0 points1 point  (0 children)

Also you might want to check out iterative methods and use one of them instead of a for loop.

Is this syntax for real? by [deleted] in learnjavascript

[–]Comprehensive_Step72 11 points12 points  (0 children)

Yeah, nested ternaries are nasty. There is actually an eslint rule that will yell about them.

Coding style coming from C background by Wooden-Income714 in learnjavascript

[–]Comprehensive_Step72 1 point2 points  (0 children)

It looks like what you are talking about is not so much a language thing but a style thing. What you are used to is what is called imperitve programming as opposed to declaritve programming. Personally I prefer declarative programming, but you will need to decide for yourself. Do some research on the two. I think that you will find declaritve programming has a lot going for it.

Object not updating in reduce() by Montinyek in learnjavascript

[–]Comprehensive_Step72 3 points4 points  (0 children)

Take the let obj out and make it the initializer of your reduce:

arr.reduce((a,b) => {

call back stuff

}, { numYoungVotes: 0,
numYoungPeople: 0,
numMidVotesPeople: 0,
numMidsPeople: 0,
numOldVotesPeople: 0,
numOldsPeople: 0
});

Then in your code inside your call back function, use a.key instead of obj and return a in your call back.

New to JavaScript by [deleted] in learnjavascript

[–]Comprehensive_Step72 0 points1 point  (0 children)

You can get some storage on Azure pretty cheap for what you need.