These are chat archives for FreeCodeCamp/HelpJavaScript

3rd
Aug 2018
Nerando Johnson
@Nerajno
Aug 03 2018 03:00
this is kinda broken..... but it wrks the test case
anyone wanna provide input
function rot13(str) {
    // LBH QVQ VG!
    str = str.toLowerCase();
    var alphabet = 'abcdefghijklmnopqrstuvxwyz'.split('');
    var result = [];
    for (var i = 0; i < str.length; i += 1) {
        var k = str[i]; // str char due iteration of var i
        console.log(k);
        var j = alphabet.includes(k);
        var rot13Shift = 13; //shift by 13 or adds 13 to the current char index
        var rot13Shifted = Number(alphabet.indexOf(k)) + rot13Shift; // the 1st iteration a rot13 shift under 25
        var rot13ShiftedB = rot13Shifted - 26; // 2nd iteration if rot13 > 26

        if (k ===' '){
            result.push(k);
        } else {
            //rot13 shift
            if (rot13Shifted < 26) {
                result.push(alphabet[rot13Shifted]);
            } else if (rot13Shifted > 25) {
                result.push(alphabet[rot13ShiftedB]);
            } else {
                console.log('');
            }
        }
        // var j = str.indexOf(str[i])+13;
        // if(j<26){
        //   console.log(alphabet[j],j,i);
        // }else{
        //   console.log("test");
        // }
    }
    console.log(result.join('').toUpperCase());
}
rot13('SERR PBQR PNZC'); //FREE CODE CAMP
abraham anak agung
@padunk
Aug 03 2018 04:15
@Nerajno you can also use String.codePointAt that refer to Unicode character. A is 65, so that way you don't need alphabet variable.
You never use variable j so you can delete it.
Prakash Kumar
@ThePrakashKumar
Aug 03 2018 06:41
When should I use curly braces in arrow function and how to write arrow function when we are not using curly braces.
Aditya
@ezioda004
Aug 03 2018 06:44
@ThePrakashKumar If the arrow function contains just 1 statement then dont use curly braces because the return will be implicit, otherwise use it.
Tiago Correia
@tiagocorreiaalmeida
Aug 03 2018 08:37
good morning
May Kittens Devour Your Soul
@diomed
Aug 03 2018 10:57
hello
could anyone tell me in this pen
how would I clear all that I wrote - without reloading page
Tiago Correia
@tiagocorreiaalmeida
Aug 03 2018 11:11
what do you mean by clear what you wrote? the right div text?
const divv = document.getElementById("result")
divv.innerText = "";
not sure if this is what you are asking
May Kittens Devour Your Soul
@diomed
Aug 03 2018 11:22
@tiagocorreiaalmeida yes, entered text that displays in right div
Nerando Johnson
@Nerajno
Aug 03 2018 12:29
@padunk gonna refactor it
Tiago Correia
@tiagocorreiaalmeida
Aug 03 2018 12:56
I guess what I pasted work @diomed ?
May Kittens Devour Your Soul
@diomed
Aug 03 2018 13:28
@tiagocorreiaalmeida what is divv
and how to connect this to html
@ezioda004 are you here somewhere?
ATom M
@ATom-M
Aug 03 2018 13:32
I can try help
Aditya
@ezioda004
Aug 03 2018 13:34
@diomed How do you want to clear the text in the right div? Like on which event?
May Kittens Devour Your Soul
@diomed
Aug 03 2018 13:36
well, I could go with a button click
that would make most sense I guess
@ezioda004 also, I have this problem when I enter first item, I forget myself and hit ENTER
this causes creation of item, without creation of it's meaning, so can it be prevented to create item, without filling both fields?
Aditya
@ezioda004
Aug 03 2018 13:41
@diomed You're storing data in myArr, so clear that array when processForm executes on click?
Tiago Correia
@tiagocorreiaalmeida
Aug 03 2018 13:44
you can use make a validation on a keypress or something like that
document.getElementById("result").innerText = "";
or as said above update the data variable first and then the innertext
ATom M
@ATom-M
Aug 03 2018 13:45
how do you guys know what @diomed is working on?
May Kittens Devour Your Soul
@diomed
Aug 03 2018 13:45
@ATom-M coz I left link to pen
in message above
ATom M
@ATom-M
Aug 03 2018 13:46
Oh okay, ty
How long ago lmao
May Kittens Devour Your Soul
@diomed
Aug 03 2018 13:46
12:57 so, not that long ago
Aditya
@ezioda004
Aug 03 2018 13:51
@diomed A simple validator for non-empty inputs
const inputArr = [0, 1].map(ind => document.querySelectorAll("input")[ind].value);
  if (inputArr[0] !== "" && inputArr[1] !== ""){
    for(let key of formData.entries()){
        myObj[key[0]] = key[1];
    }
    myArr.push(myObj);

    myObj = {};

    document.getElementById('myForm').reset();
    document.getElementById('grid-first-name').focus();
    getResult();
  }
catalin560
@catalin560
Aug 03 2018 13:54
hey guys! any idea how to remove duplicates from an array of arrays?
[[2, 9], [2, 6], [2, 9]] should be [[2, 9], [2, 6]]
I've already tried:
[...new Set(array)] in some cases for some reason it removes even unique arrays...
I've also tried:
arr1.filter((e,i) => arr2.indexOf(e) === i); didn't work
the only thing I can think of is converting the arrays to string, remove duplicates then convert back to array
May Kittens Devour Your Soul
@diomed
Aug 03 2018 13:59
thank you very much @ezioda004 :thumbsup:
Aditya
@ezioda004
Aug 03 2018 14:01
@catalin560 Yeah converting to string would work, something like this
[...new Set([[2, 9], [2, 6], [2, 9]].map(arr => JSON.stringify(arr)))].map(arr => JSON.parse(arr)) // [[2, 9], [2, 6]]
catalin560
@catalin560
Aug 03 2018 14:02
@ezioda004 nice
@ezioda004 thanks it worked like a charm!
Aditya
@ezioda004
Aug 03 2018 14:06
:thumbsup:
May Kittens Devour Your Soul
@diomed
Aug 03 2018 14:09
btw. when in JS is there no other way to select html element than getElementById("x")
Aditya
@ezioda004
Aug 03 2018 14:12
What do you mean? There isdocument.querySelector("#id")?
Simon Cordova
@gbsimon87
Aug 03 2018 14:18
@JLuboff good stuff that it went well man, and going live Monday, nice bro!
keep that up
Kelechi Chinaka
@ke1echi
Aug 03 2018 14:22
@ezioda004 what are you working on now?
Aditya
@ezioda004
Aug 03 2018 14:25
@kelechy :wave: working on backend projects, hows CS50 coming?
Kelechi Chinaka
@ke1echi
Aug 03 2018 14:27
@ezioda004 :wave: starting reading up on pset4 today
fcc backend projects? @ezioda004
Aditya
@ezioda004
Aug 03 2018 14:31
@kelechy Oh nice, goodluck! Yes, fcc projects.
Kelechi Chinaka
@ke1echi
Aug 03 2018 14:42
how do you combine both without having headaches? @ezioda004
ATom M
@ATom-M
Aug 03 2018 14:43
I might check the CS50 course out, it looks useful
Which site do you use online
Tiago Correia
@tiagocorreiaalmeida
Aug 03 2018 14:45
@diomed you can go by class or even by element, but by element or class you probably have more one of the type so you will need to loop trough the elements unthil you find the one you are looking for
Kelechi Chinaka
@ke1echi
Aug 03 2018 14:45
yea.. go knock it out @ATom-M
ATom M
@ATom-M
Aug 03 2018 14:45
Did you use the Harvard site?
Kelechi Chinaka
@ke1echi
Aug 03 2018 14:47
edx
Aditya
@ezioda004
Aug 03 2018 14:54
@kelechy I havent touched CS50 after pset4, no idea when I'll continue
@ATom-M Its pretty good, they also have similar course for mobile/game dev if you're interested in that.
Jason Luboff
@JLuboff
Aug 03 2018 15:05
@gbsimon87 Thanks man!
Simon Cordova
@gbsimon87
Aug 03 2018 15:17
@cmccormack @JLuboff
I guess when it rains it pours,
Five companies know about my visa need and I'm in the third phase of interviewing with 4 of them
One has offered the job :)
52 interviews, 50 freaking 2 in a month and a half
Christopher McCormack
@cmccormack
Aug 03 2018 15:27
@gbsimon87 damn that's some gumption! I can't believe you actually got 52 interviews, I feel like I would get 1 or 2 if I submitted 100 requests
Jason Luboff
@JLuboff
Aug 03 2018 15:27
Awesome man!
Ya.. in the past when I've been looking for jobs, its usually 1-2 in every 50-100 submissions lol
alpox
@alpox
Aug 03 2018 15:38
Is that normal in the USA? O.o
Jesus I dont know if I could do that
Jason Luboff
@JLuboff
Aug 03 2018 15:39
Job market can be rather saturated
Or they're looking for a very specific individual
alpox
@alpox
Aug 03 2018 15:39
I see
Jason Luboff
@JLuboff
Aug 03 2018 15:40
Or they have stupid requirements like
Bachelors degree
3+ years experience
OR
If no degree, 10+ years experience
alpox
@alpox
Aug 03 2018 15:40
Yea that are pretty hard requirements
Jason Luboff
@JLuboff
Aug 03 2018 15:41
My biggest issue probably was the no bachelors even though I had certifications, etc but meh.. luckily my current job liked what they saw!
alpox
@alpox
Aug 03 2018 15:45
Luckily not all are that strict when they see that you can program :D
But what I see is that with a degree they just have more expectations of you :/
Jason Luboff
@JLuboff
Aug 03 2018 15:49
Its only becuase of this job that I started programming hah
Jason Luboff
@JLuboff
Aug 03 2018 15:54
Ugh.. trying to wrap my brain around my own query...
alpox
@alpox
Aug 03 2018 15:55
Thats a cool thing then :D did you get that opportunity or were you already working there?
Did you make a 300 line select? :D
Jason Luboff
@JLuboff
Aug 03 2018 15:57
I was already working here as the help desk/network tech (not really a true help desk position though...as I was always involved with servers and building them up, etc) and I happened to find FCC and started going through it during downtime as to give myself something to do. The DBA/programmer we had, had been pushed into semi-retirement and so last year I approached my boss asking what more I could do to get a raise and here I am now, becoming the DBA/programmer
And no, not 300 lines lol. But the query is to determine when to email an user. So basically I need to email them if they haven't completed the item, its been more than 7 days since creation of the item, more than 7 days since last email sent unless they've filled in the reviewed date in which case it should only email every 30 days

So...I have this currently, but it's not right

 WHERE ai.CompletionDate IS NULL
                AND (DATEDIFF(DAY, CreationDate, GETDATE()) >= 7
                AND (ReviewDate IS NULL OR DATEDIFF(DAY, ReviewDate, GETDATE()) >= 30)     
                AND (LastEmailSent IS NULL OR ((DATEDIFF(DAY, ReviewDate, GETDATE()) >= 30 OR DATEDIFF(DAY, LastEmailSent, GETDATE()) >= 7)));

Since its not accounting for lastemailsent properly

alpox
@alpox
Aug 03 2018 16:02
Ah :D cool thing! Congrats to your new position (although late :D)
Jason Luboff
@JLuboff
Aug 03 2018 16:02
Thanks, they haven't officially given me the title though lol
alpox
@alpox
Aug 03 2018 16:08
The last line seems to have a problem but its hard to track cause of the weird parens :D
Jason Luboff
@JLuboff
Aug 03 2018 16:08
Ya it is the last line thats the issue
alpox
@alpox
Aug 03 2018 16:09
Id just nest that stuff better
Jason Luboff
@JLuboff
Aug 03 2018 16:09

Essentially I need to have

if reivewDate is not null, then send only every 30 days 
else send every 7

I know I can get it, just sometimes wrapping my head aorund the proper use of AND and ORs can get confusing lol

Kudzu
@czhower
Aug 03 2018 16:09
If you need to break a query up you can split it into views / SPs. Makes it simpler to deal with in pieces, and sometimes can result in perf benefits if done right.
Jason Luboff
@JLuboff
Aug 03 2018 16:10
The query itself isn't terrible, its just getting the proper 7 vs 30 day emailing part lol
alpox
@alpox
Aug 03 2018 16:10
(isCreated > 7 && lastMail > 7 && !reviewed) || (reviewed && reviewed > 30)
(fake code ofc.)
Jason Luboff
@JLuboff
Aug 03 2018 16:11
Thats some wierd looking SQL :P
alpox
@alpox
Aug 03 2018 16:11
Or better the other way round
Simon Cordova
@gbsimon87
Aug 03 2018 16:12
@JLuboff @cmccormack the real reason there were so many is because they weren't all registered sponsors that had the ability to sponsor
alpox
@alpox
Aug 03 2018 16:12
(reviewed && reviewed > 30) || (isCreated > 7 && lastMail > 7)
Simon Cordova
@gbsimon87
Aug 03 2018 16:12
But at least I've got 5 atm that know the situation and 1 has offered - I'm ecstatic
alpox
@alpox
Aug 03 2018 16:13
@JLuboff this would make the logic more readable in this constellation :D
Jason Luboff
@JLuboff
Aug 03 2018 16:14
@alpox However, with that query pseudocode, you don't account for last email sent for reviewed, becuase we still only want to send it out every 30 days. So if we reviewed it, we wait 30 days, then send the first email, at which point another email should go out 30 days later unless its been completed
@gbsimon87 So that means you're good to stay?
alpox
@alpox
Aug 03 2018 16:15
@JLuboff right, but thats only one clause more :D
Id write it if i would not be on phone :D
Jason Luboff
@JLuboff
Aug 03 2018 16:15
Don't worry about it, thats my challenge for hopefully just the morning and not the full day lol
alpox
@alpox
Aug 03 2018 16:18
Morning? I always forget about time differences...
Its 18:18 here :D
Jason Luboff
@JLuboff
Aug 03 2018 16:19
18:18? We speak in Freedom hours here (joking of course)! It's only 9:18 AM here
Jefferson
@jeffersonnnn
Aug 03 2018 16:20
you know, i really hate times like this (this also indicative of my overall programming aptitude) but i am reading up on implementations of Hash Tables in JS and for the life of me, i can't understand how var tuple = bucket[i]; works in a for loop that looks something like this for (var i = 0; i < bucket.length; i++) { var tuple = bucket[i];
Help, please?
alpox
@alpox
Aug 03 2018 16:22
@jeffersonnnn there is no hash table in your code. What do you not understand about that code and where is your connection to hash tables?
@JLuboff freedom hours? I would like some freedom...
Jefferson
@jeffersonnnn
Aug 03 2018 16:27

@alpox sigh. okay, look at what i mean?

  var override = false;
  for (var i = 0; i < bucket.length; i++) {
    var tuple = bucket[i];
    if (tuple[0] === key) {
      //overide value stored at this key
      tuple[1] = value;
      override = true;
    }
  }

i would like to know what the var tuple = bucket[i]; means

thanks man
Christopher McCormack
@cmccormack
Aug 03 2018 16:27
@JLuboff hah freedom hours? The MILITARY uses it
Jason Luboff
@JLuboff
Aug 03 2018 16:28
@alpox Ya.. joking about how us american's like to call everything freedom... like freedom fries and freedom toast and... freedom meters...and.. freedom pies... and.. (I'm making stuff up now)
alpox
@alpox
Aug 03 2018 16:28
@jeffersonnnn it takes out the value at position i (i is a number between 0 and the length of the array bucket) of the array bucket
Jason Luboff
@JLuboff
Aug 03 2018 16:28
@cmccormack The military knows not of freedom!
alpox
@alpox
Aug 03 2018 16:29
@jeffersonnnn the value then gets assigned to a new variable named tuple
Christopher McCormack
@cmccormack
Aug 03 2018 16:29
it's kind of true, the US Military is not covered under the Constitution but instead under the Uniform Code of Military Justice. But 24hour clock is still far superior
alpox
@alpox
Aug 03 2018 16:31
@jeffersonnnn the code inside of the {} in the forloop gets executed as many times as there are values in the bucket. The variable i has a different number each time the for loop content is executed. It counts from 0 in the first execution to the length of the bucket minus one in the last execution
Jason Luboff
@JLuboff
Aug 03 2018 16:31
@cmccormack Psh... but then I need to remember 24 numbers instead of 12!
Christopher McCormack
@cmccormack
Aug 03 2018 16:31
haha
Jefferson
@jeffersonnnn
Aug 03 2018 16:37
@alpox thank you, kind internet stranger! That unclogged things up rather nicely. Off to hash tables then!
Tom
@moT01
Aug 03 2018 16:38
@cmccormack im catchin up
Christopher McCormack
@cmccormack
Aug 03 2018 16:38
@moT01 haha well now it's on!
Jason Luboff
@JLuboff
Aug 03 2018 16:39
@moT01 Good job
Tom
@moT01
Aug 03 2018 16:40
thanks
didnt exactly put my heart and soul into the two projects i needed to finish - but they're alright and they pass the tests
Christopher McCormack
@cmccormack
Aug 03 2018 16:43
@moT01 the race is only over when you have the tests passing for all the old projects too, fyi :)
Also I didn't know we were racing
Tom
@moT01
Aug 03 2018 16:45
yea right
you go ahead
Christopher McCormack
@cmccormack
Aug 03 2018 16:46
haha I already have, almost done
a few more D3 projects to redo
Tom
@moT01
Aug 03 2018 16:47
really
dont lie now
Christopher McCormack
@cmccormack
Aug 03 2018 16:48
I swear - they're kind of fun to go back and do
although some of those tests will have you ripping out your hair until you realize what exactly it was looking for
alpox
@alpox
Aug 03 2018 16:52
@cmccormack its always fun to play with d3 :D
I had the luck to build a quite fun thing at my job with it, so fun :D
Christopher McCormack
@cmccormack
Aug 03 2018 16:53
@alpox it really is fantastic, and the examples are so good!
I need to find a reason to use it though, hoping my wife will let me make some stuff for her for her data science work
alpox
@alpox
Aug 03 2018 16:54
Would sure be fun :D
Although svg animations are more fun than static stuff :D
Jason Luboff
@JLuboff
Aug 03 2018 16:55
Alright...think I got my query right now
Christopher McCormack
@cmccormack
Aug 03 2018 16:56

I have a regex question. Say you have a string of whitespace at the beginning of a line, and you want to capture only the whitespace of a certain length, followed by any non-whitespace character, like so:

policy
    match
         something
    set
         something

I want to replace only certain lengths of whitespace with something else.
^\s{4} for example would match line 2 and line 3 but I only want to match line 2

alpox
@alpox
Aug 03 2018 16:58
@cmccormack `/^\s{4}\S
Damn phone
Tom
@moT01
Aug 03 2018 16:58
i think you can just add another number there for the max you want to match
alpox
@alpox
Aug 03 2018 16:58
Sends unfinished stufd
Christopher McCormack
@cmccormack
Aug 03 2018 16:58
I can add a non-whitespace character to the previous regex, but then I would have to somehow add that character back in
Tom
@moT01
Aug 03 2018 16:58
^\s{2,4}
match between 2 and 4 spaces?
alpox
@alpox
Aug 03 2018 16:59
/^\s{4}(\S)/
Like this you capture the last character
So you can put it in again
Either with a replacement function or $1
Christopher McCormack
@cmccormack
Aug 03 2018 16:59
ah a capturing group
I'm doing this with Sublime text find/replace, it supports regex, I'll see if it does capturing groups as well
alpox
@alpox
Aug 03 2018 17:00
I think it does
But likely references are \1
Backslash instead of dollar
Christopher McCormack
@cmccormack
Aug 03 2018 17:02
that's it!
Thank you @alpox @moT01 !
alpox
@alpox
Aug 03 2018 17:02
@cmccormack np
Christopher McCormack
@cmccormack
Aug 03 2018 17:02
I guess I just assumed it wouldn't do capturing groups and couldn't think of another way
alpox
@alpox
Aug 03 2018 17:02
Most editors with regex support also support capturing groups :D
I think I havent come across any which did not
Christopher McCormack
@cmccormack
Aug 03 2018 17:03
yeah stupid assumption
alpox
@alpox
Aug 03 2018 17:03
Just the syntax is different as times
Simon Cordova
@gbsimon87
Aug 03 2018 17:03
@JLuboff that would give me a permit to work and the right to stay indeed.
I mean I'm not even looking to stay here forever - I do miss home.
alpox
@alpox
Aug 03 2018 17:03
@cmccormack sadly, regex is no standard and there are various implementations
Simon Cordova
@gbsimon87
Aug 03 2018 17:04
But the lady is here and it's tough to let her go Andy
alpox
@alpox
Aug 03 2018 17:04
Okay there is a regex standard... But only a few follow it :D
Jason Luboff
@JLuboff
Aug 03 2018 17:04
@gbsimon87 So bring the lady home ;)
Christopher McCormack
@cmccormack
Aug 03 2018 17:05
that's going to save me quite a bit of time cleaning up all these docs, thanks again
alpox
@alpox
Aug 03 2018 17:06
@cmccormack I used regex so many times in editors... Its a real help :D
Christopher McCormack
@cmccormack
Aug 03 2018 17:09
@alpox yeah I used to avoid it but just like everything else the more you use it the more you find uses for it
Bjorn van de Peut
@bjorno43
Aug 03 2018 17:12
Should be carefull with regex though. Regex should be treated as a last resort. Not as your go-to solution
Simon Cordova
@gbsimon87
Aug 03 2018 17:12
@JLuboff I would but she's American
She'd get caught in the same situation I'm in
Christopher McCormack
@cmccormack
Aug 03 2018 17:12
I know well enough when to use Regex
Simon Cordova
@gbsimon87
Aug 03 2018 17:12
Man I'm ecstatic
Christopher McCormack
@cmccormack
Aug 03 2018 17:13
I don't think it's always a last resort either, it fills a specific technical need
Bjorn van de Peut
@bjorno43
Aug 03 2018 17:13
@cmccormack I know. I ment it in general, not to you or @alpox I know both of you are smart enough to know that yourself :P
Christopher McCormack
@cmccormack
Aug 03 2018 17:15
I had to take a class on theoretical computer science for my CS degree, you learn a lot about what RegEx really is, it was pretty interesting and made me a little less scared of it
well, you learn about Grammars, and that Regular Expression falls into that category
Bjorn van de Peut
@bjorno43
Aug 03 2018 17:20
Well I'm not scared of Regex. I definitely love it! I just know it rly uses a lot of resources. That's why I prefer to avoid it
Simon Cordova
@gbsimon87
Aug 03 2018 17:21
Resources in what way? Performance heavy?
Jason Luboff
@JLuboff
Aug 03 2018 17:24
@gbsimon87 Which means she'll be in your same position at some point anyhow, no?
Bjorn van de Peut
@bjorno43
Aug 03 2018 17:25
@gbsimon87 Ye. Regex rly does a number on the CPU. Either the server's CPU if used server side or the users CPU when used client side. Use it too much and you'll start noticing some serious slow reaction times.
Ozarion
@Ozarion
Aug 03 2018 17:26
Hey everyone :)
Kudzu
@czhower
Aug 03 2018 17:26
Client side its rarely going to be enough to notice unless you are doing some heavy processing client sdie.
Simon Cordova
@gbsimon87
Aug 03 2018 17:26
@JLuboff funny enough, yes, I'd suppose.
But by then I'd probably have fully locked her down
Jason Luboff
@JLuboff
Aug 03 2018 17:27
@gbsimon87 Then why not fully lock her down now ;)
Simon Cordova
@gbsimon87
Aug 03 2018 17:28
@bjorno43 good to know. Id like to dive deeper into it tbh I just have mongo and node next on the pipeline
Ozarion
@Ozarion
Aug 03 2018 17:28
I've completed this project, it's working (as I see it) absolutely fine, Will someone please help me, why it is not passing the test cases?
https://codepen.io/ozarion/pen/VBdYNa?editors=0010
Simon Cordova
@gbsimon87
Aug 03 2018 17:28
@JLuboff lolol she saw that msg
Bjorn van de Peut
@bjorno43
Aug 03 2018 17:28
@czhower True. Client side you won't notice it unless something heavy is going on. Luckily that's rarely the case.
Jason Luboff
@JLuboff
Aug 03 2018 17:29
@gbsimon87 Shit man.. get it done then
Kudzu
@czhower
Aug 03 2018 17:34
When I write client code I dont optimize as much. Its not worth the effort. I dont make it slow, but I simply dont bother with a lot fo the same optimizations I do for server code.
Saves a fair bit of time overall :)
Ozarion
@Ozarion
Aug 03 2018 17:35
Where can I ask for React specific help?
Christopher McCormack
@cmccormack
Aug 03 2018 17:36
@Ozarion you can ask in here
React is Javascript
Help channel is also fine
of HelpFrontEnd
Ozarion
@Ozarion
Aug 03 2018 17:36
@cmccormack I've completed this project, it's working (as I see it) absolutely fine, Will someone please help me, why it is not passing the test cases?
https://codepen.io/ozarion/pen/VBdYNa?editors=0010
Christopher McCormack
@cmccormack
Aug 03 2018 17:37
@Ozarion you can see the errors if you click the button in the test suite
Ozarion
@Ozarion
Aug 03 2018 17:37
Yeah. What it states is working just fine. I can't understand what is wrong.
Christopher McCormack
@cmccormack
Aug 03 2018 17:37
@Ozarion that project was probably the most difficult for me to get the tests to pass - one thing you should do is find a more accurate timer to use
that may resolve some of your issues
Ozarion
@Ozarion
Aug 03 2018 17:38
@cmccormack I've done everything from scratch.
Christopher McCormack
@cmccormack
Aug 03 2018 17:38
@Ozarion It may seem to work fine but that may not be enough to past the test cases they wrote
Ozarion
@Ozarion
Aug 03 2018 17:39
@cmccormack Wouldn't changing the timer mean changing most of my code as well. :/
Christopher McCormack
@cmccormack
Aug 03 2018 17:39
@Ozarion what I mean is if you are using setInterval it may not be accurate enough
@Ozarion maybe
Ozarion
@Ozarion
Aug 03 2018 17:40
yes. I'm using setInterval. Is there an alternative way?
Christopher McCormack
@cmccormack
Aug 03 2018 17:40
The example project imports one if you want to use that . I built one using class if you are interested I can share
@Ozarion with React you may need to be careful with your setState - remember it is asynchronous and the test cases are very tight
I had to jump into the test suite bundle a few times to try and figure out what was failing
which is not easy
@Ozarion gist if you are interested
Ozarion
@Ozarion
Aug 03 2018 17:45
@cmccormack damn! Good to hear I'm not the only one who struggled with this. Yes, If it's fine I'd like to use your timer implementation. Please share. :)
@cmccormack Thank you
Christopher McCormack
@cmccormack
Aug 03 2018 17:46
@Ozarion most other projects it was easy to add the tests and get to pass, but this one makes a lot of assumptions that don't translate well to the user stories
Ozarion
@Ozarion
Aug 03 2018 17:47
@cmccormack totally agree.
alpox
@alpox
Aug 03 2018 17:48
@Ozarion I notice your beep occurs only 1 sec after the timer reaches 0
Christopher McCormack
@cmccormack
Aug 03 2018 17:48
@Ozarion I probably wasted the most time with a minor oversight - I didn't add a leading zero to the minutes because I didn't think that was necessary - boy was I wrong
Ozarion
@Ozarion
Aug 03 2018 17:55
@cmccormack Nothing is too small when passing test cases. XD
@alpox Yeah. Just noticed it. Let me fix that and check again. Hope that's the issue :)
Christopher McCormack
@cmccormack
Aug 03 2018 17:56
absolutely :) I think I may submit some hints to the user stories, some of them can be really hard to pass if you don't know specifically what it's looking for
One example is the D3 projects - you cant just set x y to line up how you want, you have to set them to match the axis, and use transpose to then move them later if needed
Ozarion
@Ozarion
Aug 03 2018 18:00
@cmccormack Yeah. That's a great idea. Hints would definitely encourage new learners, and make it a lot more fun actually.
Christopher McCormack
@cmccormack
Aug 03 2018 18:02
I do worry these tests may discourage some, but I also know if they can succeed and pass them all that will be incredibly rewarding
alpox
@alpox
Aug 03 2018 18:04
@cmccormack and give a great sense of accomplishment? :laughing:
Ozarion
@Ozarion
Aug 03 2018 18:04
Yeah, making test hard is good but like you said, some tests force a lot of syntax which makes it PITA, i.e. In one previous projects (cant remember the name but it was front end section), One test case was failing because I was using anchor button instead of button even though everything else was good. And I was losing my shit. XD
Christopher McCormack
@cmccormack
Aug 03 2018 18:06
The Drum exercise, if I remember correctly, actually encourages a worse way to implement the audio than other options, IMO.
they aren't perfect but I guess we can contribute if we want to make them better
Ozarion
@Ozarion
Aug 03 2018 18:07
Agree.
Jason Luboff
@JLuboff
Aug 03 2018 18:35
Er... this is frustrating...promise rejections aren't getting caught properly..
Christopher McCormack
@cmccormack
Aug 03 2018 18:40
@JLuboff did you add reject in your promises?
I think I remember you only having resolve in some
that could have been someone else though
alpox
@alpox
Aug 03 2018 18:41
@JLuboff Suure they are
Jason Luboff
@JLuboff
Aug 03 2018 18:45
Yup, have reject. In fact, it was @alpox who helped me with it originally! :smirk:

Here's the setup

exports.actionItem = () => {
  const request = new db.Request();

  return request
    .query(`query goes here to make @alpox happy
      `)
    .catch((err) => {
      const errorMsg = `(update)actionItem Error: ${err}`;
      return Promise.reject(errorMsg);
    })
    .then(result => result.recordsets);
};

From DB file, I see the errorMsg there in my console.. attached to the unhandled rejection error..

  app.route('/reviewRequest/:requestID/actionItem').post(upload.single('fileUpload'), authUser, isAuthenticated, (req, res) => {
    read.userInfo(user).then((userInfo) => {
      update.actionItem(
      ).then((result) => {
        return res.sendStatus(200);
      });
    })
      .catch((err) => {
        const errorMsg = `Route: /reviewRequest/${requestID}/actionItems Query: ${err}`;
        console.error(error(errorMsg));
        nodeMailer.generalError(errorMsg);
        return res.sendStatus(500);
      });
  });

And the actual route. I removed a bunch of what I assume to be non-important code

alpox
@alpox
Aug 03 2018 18:48
.query(`query
      `)
Huh
Jason Luboff
@JLuboff
Aug 03 2018 18:49
I removed the query and put query in its place lol
alpox
@alpox
Aug 03 2018 18:49
aha :D
Jason Luboff
@JLuboff
Aug 03 2018 18:49
Didn't think it was needed ;)
alpox
@alpox
Aug 03 2018 18:49
Yes that ok :D was just looking weird
Jason Luboff
@JLuboff
Aug 03 2018 18:49
Changed it ;)
alpox
@alpox
Aug 03 2018 18:50
@JLuboff You cannot get an error happening in update.actionItem now
Because the nested (DONT NEST!) promise is not returned and integrated into the promise chain
Jason Luboff
@JLuboff
Aug 03 2018 18:51
mmm...suggestion?
alpox
@alpox
Aug 03 2018 18:51
read.userInfo(user)
      .then((userInfo) => update.actionItem())
      .then((result) => res.sendStatus(200))
      .catch((err) => {
        const errorMsg = `Route: /reviewRequest/${requestID}/actionItems Query: ${err}`;
        console.error(error(errorMsg));
        nodeMailer.generalError(errorMsg);
        return res.sendStatus(500);
      });
Another general suggestion is that you should use an error handler as last middleware in the express middleware pipeline
And not send each error individually
Makes the error handling cleaner
Jason Luboff
@JLuboff
Aug 03 2018 18:54
Alright, so I need to restructure my routes that contain multiple promises
alpox
@alpox
Aug 03 2018 18:54
You can then just throw in errors with
(req, res, next) => {
 .....
 next(internalServerError("my fancy error message"));
 .....
}
@JLuboff Well its just a suggestion - its not necessary to make this work :D
Jason Luboff
@JLuboff
Aug 03 2018 18:55
More so for my promise rejection to get caught
alpox
@alpox
Aug 03 2018 18:55
For that to get caught I sent you the code above
Jason Luboff
@JLuboff
Aug 03 2018 18:55
Correct :)
And thank you
I'll worry about the error handling a little later.
alpox
@alpox
Aug 03 2018 18:56
Sure :)
Jason Luboff
@JLuboff
Aug 03 2018 18:56

I do have two error handler listeners

if (process.env.NODE_ENV === 'production') {
  process.on('uncaughtException', (err) => {
    console.error(err.stack);
    nodeMailer.uncaughtException(err);
  });
  sql.on('error', (err) => {
    console.error(err);
    nodeMailer.uncaughtException(err);
  });
}

But obiviousily thats not along with what you're suggesting

alpox
@alpox
Aug 03 2018 18:57
These look like very general error capturing but they don't help you to send error information back to the user of the api
Jason Luboff
@JLuboff
Aug 03 2018 18:57
Psh... forget the user! :P
alpox
@alpox
Aug 03 2018 18:58
:D
Jason Luboff
@JLuboff
Aug 03 2018 18:59
I'll probably come back to you next week about better error handling. Trying to get my queries updated for my new table structure so I can have that implemented by this afternoon
This will help you if you go for that
Jason Luboff
@JLuboff
Aug 03 2018 19:00
I'll give it a read, thanks
They have some good best practice articles on there
alpox
@alpox
Aug 03 2018 19:02
Yea I see that they also add new information with better practices at time
Jason Luboff
@JLuboff
Aug 03 2018 19:03
I implemented compression, and I think some of the error handling that I have becuase of one of their articles
Ozarion
@Ozarion
Aug 03 2018 19:46
Just got the Front End Libraries Certification. \(~o~)/
Brad
@bradtaniguchi
Aug 03 2018 19:49
@Ozarion nice, congratz :D
alpox
@alpox
Aug 03 2018 19:49
@Ozarion gratulations!
Ozarion
@Ozarion
Aug 03 2018 19:50
Thank you. @bradtaniguchi @alpox :)
I'm trying complete it ASAP so that I can do some open source collaboration and start making some money by either getting a job or freelancing.
Cuz I'm an 18 year old guy going through mid-life crisis. XD
Diego Mayer
@Chrono79
Aug 03 2018 19:56
That makes a lot of us elders then :crying_cat_face:
Ozarion
@Ozarion
Aug 03 2018 20:11
LOL. No. The way I see it, It makes you more experienced ;)
Jason Luboff
@JLuboff
Aug 03 2018 20:15
Did FCC start doing the open source collab stuff again?
Ozarion
@Ozarion
Aug 03 2018 20:17
I've not collabed so don't really know. :/
Kudzu
@czhower
Aug 03 2018 20:18

"Cuz I'm an 18 year old guy going through mid-life crisis"

Are you planning to only live till your mid 30s?

Jason Luboff
@JLuboff
Aug 03 2018 20:28
Man that would be depressing...
tundeiness
@tundeiness
Aug 03 2018 20:29
hI guys. Here is my modest product landing page created since I had to restart some new FCC projects. Please help critique..I need feedback especially it behaviour in mobile devices. Thanks. and Prolly help drop a solution as well? https://codepen.io/highness/full/eKaogZ/
Christopher McCormack
@cmccormack
Aug 03 2018 21:43
@tundeiness hey looks pretty good! The footer is a little large considering the items are all on the bottom, but the page is nice and responsive, looks good!
Maybe fill in the features a bit more though :)
Mark Sorce
@msorce
Aug 03 2018 21:57
@tundeiness that is a rather large header/nav at smaller screen sizes. maybe you can hide some of that content in the collapsable menu?
tundeiness
@tundeiness
Aug 03 2018 22:33
@cmccormack I was considering reducing the footer though. Thanks for the feedback I'll work on that.
@msorce noticed that as well...maybe I was just being lazy. However I will revert.