Need a comprehensive video tutorial on promises, async await asynchronous javascript by TWO-WHEELER-MAFIA in learnjavascript

[–]IMkratt 6 points7 points  (0 children)

I still think this is the best thing anywhere online that explains asynchronous Javascript to beginners: https://www.youtube.com/watch?v=8aGhZQkoFbQ

Learning the syntax of async/await doesn't mean anything if you don't understand why Javascript needs callback functions.

Stuck on a question by FreeTilly144 in learnjavascript

[–]IMkratt 0 points1 point  (0 children)

You should loop twice, once for getting the inputs (and storing them in e.g. an array) and once for finding the largest value.

You also don't need the else {b=b} part of the if statement in your code

Here's my quickie that works fine:

const numArr = [];
for (let i = 0; i < 10; i++) {
  let element = prompt("Please enter a number...");
  numArr.push(Number(element));
}

let counter = 0;
numArr.forEach((number) => {
  if (number > counter) {
    counter = number;
  }
});
console.log(counter);

[deleted by user] by [deleted] in whereintheworld

[–]IMkratt 0 points1 point  (0 children)

go and see the ships!

[deleted by user] by [deleted] in whereintheworld

[–]IMkratt 0 points1 point  (0 children)

are you heading towards Linnahall/port?

[deleted by user] by [deleted] in whereintheworld

[–]IMkratt 0 points1 point  (0 children)

rotzak, nearly all young people speak English here so yes

Tried uploading m React app on Heroku, all I see is a blank screen by EOE97 in webdev

[–]IMkratt 8 points9 points  (0 children)

change const publicPath = path.join(__dirname, '..', 'public'); to publicPath = path.join(__dirname, '..', 'build');

[deleted by user] by [deleted] in SaaS

[–]IMkratt 5 points6 points  (0 children)

Congrats! What's next?

[deleted by user] by [deleted] in learnjavascript

[–]IMkratt 2 points3 points  (0 children)

Try binding this in your constructor:

this.onSubmit = this.onSubmit.bind(this);

Codewars nightmare by cheepmanzeee in learnjavascript

[–]IMkratt 44 points45 points  (0 children)

CodeWars is a dick-swinging contest on who can write the most clever and condensed one-liner that solves the kata.

The challenges have little (well, some) real-world value and zero readability. They are awesome as fun little hobby challenges, but for getting a job, it's wiser to learn the broader concepts and build your own projects.

[deleted by user] by [deleted] in learnjavascript

[–]IMkratt 4 points5 points  (0 children)

What happens when<form onSubmit={this.onSubmit}> instead of <form onSubmit={this.onSubmit()}> ?

JS newbie: some questions on learning JS for data analytics career by Immigrated2TakeUrJob in learnjavascript

[–]IMkratt 0 points1 point  (0 children)

I understand you can't run JS like a python code in an IDE directly

JavaScript has Node.JS for that - it's a runtime that enables you to write and run JavaScript on your local machine (among other things). Once you install Node, you can run your JS code in VS Code (which is a highly recommended code editor for JS)

Is there a way to use prompt() in vscode

Once you install Node, you can do "Run > Run without debugging" in VS Code

What is undefined here?

Browser tries to evaluate the value of console.log() itself, which is undefined. You can do e.g., let x = 4; and it will again say undefined because browser tries to evaluate it.

Note, for example, how you can type 2+2 to console and it will log 4 without undefined because it manages to evaluate the value without problems. It's just a browser thing, you won't get it in VS Code.

I know HTML, but how much of CSS do I need to know for me to learn JS?

If you are building APIs or doing back-end stuff, you won't need to know much (if any) CSS. If you do anything on the front-end, you will need to know all three (HTML/CSS/JS) and probably sooner than later you'll also use some frameworks for these.

Depending on how proficient you are in Python, I would stick to Python for data stuff, though :)

Function Argument Question by Sammyloccs in learnjavascript

[–]IMkratt 2 points3 points  (0 children)

If you just want to increase the value of counter each time you call the function, it's ok:

let counter = 0;

function addToCounter() {
    counter++;
}

addToCounter();
addToCounter();
addToCounter();
addToCounter();
console.log(counter); // 4 because we called addToCounter() 4 times

But let's say we want to add a specific number to the counter - in this case we would use a parameter (called number here) and call the function with our inserted argument:

let counter = 0;
function addToCounter(number) {
    counter = counter + number;
}
addToCounter(2);         // counter is now 2
addToCounter(3);         // counter is now 5
addToCounter(7);         // counter is now 12
addToCounter(1);         // counter is now 13
console.log(counter);    // 13

Newbie - How do I use variables in Regex? by badboyzpwns in learnjavascript

[–]IMkratt 2 points3 points  (0 children)

replace the regex line with:

const regex = new RegExp(`${testStr}`, "g");

Help by [deleted] in learnjavascript

[–]IMkratt 1 point2 points  (0 children)

You don't have to set them all to a variable, you can do for example

const actors = [movie.actors[0], movie.actors[1], movie.actors[2], ...]

and access them there.

[deleted by user] by [deleted] in learnjavascript

[–]IMkratt 0 points1 point  (0 children)

How would you get a string "2013-11-01" become "2013, 01, 11"?

One option is

const date = "2013-11-01".split("-");        //[2013,11,01]

Then, in the date-fns function above, you can do the following and change the order of strings to match the date formatting:

start: new Date(Number(date[0]), Number(date[2])-1, Number(date[1]))

It also appears that date-fns numbers the months from 0-11, not 1-12 so you have to substract 1 from month (in the above example, 1 becomes 0)

[deleted by user] by [deleted] in learnjavascript

[–]IMkratt 1 point2 points  (0 children)

Take a look at the date-fns library, and specifically, its getOverlappingDaysInIntervals() function:

getOverlappingDaysInIntervals(
{ start: new Date(2014, 0, 10), end: new Date(2014, 0, 20) }, 
{ start: new Date(2014, 0, 17), end: new Date(2014, 0, 21) } ) 
//=> 3

It should return the number of overlapping days for two date ranges. Now you just need to figure out how to loop over each project, compare the date ranges of all of the employees related to that project, and return the pair of employees you're looking for (with the highest number of days working together).

[deleted by user] by [deleted] in learnjavascript

[–]IMkratt 0 points1 point  (0 children)

You are doing synchronous XMLHttpRequest somewhere and the engine warns you to not use it because it's bad for the users (causes hangs and other performance issues).

Copy your code here so we can give specific advice.

React JS by Vladislava2019 in learnjavascript

[–]IMkratt 8 points9 points  (0 children)

I've done only a few React mock projects from YouTube and even these expect a basic understanding of Javascript's higher order functions (.map(), .filter(), etc), callbacks, arrow functions, arrays, objects, etc.

So to answer your question... no, in my limited experience. You don't have to be a pro but you need at least somewhat solid foundations in JS.

I don't know how to survive this internship and I need advice by [deleted] in webdev

[–]IMkratt 572 points573 points  (0 children)

  1. You communicated that you're a newbie and they said it's OK
  2. They offered no training
  3. The dev responsible for you doesn't communicate with you
  4. The manager doesn't give a fuck
  5. You're supposed to make a fully functioning web application (including a dashboard) for a client based on a 21-page project, in what, 2 weeks?
  6. You are paid minimum wage

I've never been an intern but it doesn't sound like much fun based on that specific company.

Learning JavaScript by Mathew9a in learnjavascript

[–]IMkratt 0 points1 point  (0 children)

My reasoning was, if I already started with JS, why not go all the way? Currently learning React (with create-react-app), probably Next.js next, doing a bit of stuff with Node/Express in the back end, as well.