These are chat archives for FreeCodeCamp/Help

1st
May 2018
Henry
@GitHub-Henry
May 01 2018 02:49 UTC
This bit of regex made me say, wow.
Kyle Holm
@thekholm80
May 01 2018 02:55 UTC
@GitHub-Henry i learned a fun way to do stuff like that
oh wait, it wouldn't work here lol never mind
Henry
@GitHub-Henry
May 01 2018 02:58 UTC
I'm trying to up my regex game. Eventually, I'll get to the point where writting good regex will be naturual for me.
Kyle Holm
@thekholm80
May 01 2018 02:59 UTC
i made an effort to learn some, so i'm not 100% horrible anymore, more like 96% horrible
srpalomino
@srpalomino
May 01 2018 02:59 UTC
Hey everyone! Can anyone help me with bootstrap?
Joseph
@revisualize
May 01 2018 04:35 UTC
log
commands
@camperbot
@srpalomino Thanks
crap
Norvin Burrus
@ndburrus
May 01 2018 06:22 UTC
@srpalomino these may be helpful: :sparkles:
Daniel Simeonov
@dbsimeonov
May 01 2018 08:50 UTC
Guys what options I have if I have a shopping list, and I want to filter it by price/name. I need to do html data attributes and to store them into array?
Kaz Baig
@kbaig
May 01 2018 14:53 UTC
:wave: friendos
How's it goin
Christopher McCormack
@cmccormack
May 01 2018 14:55 UTC
@kbaig yo!
Kaz Baig
@kbaig
May 01 2018 14:55 UTC
@cmccormack long time :)
Christopher McCormack
@cmccormack
May 01 2018 14:56 UTC
@kbaig you just don't visit the other rooms much anymore :D
Kaz Baig
@kbaig
May 01 2018 14:56 UTC
I say hello here and that's usually it these days yeah
Been slumpin'
Trying to get back into it via CS50
Christopher McCormack
@cmccormack
May 01 2018 14:57 UTC
Is that the one with Python?
Kaz Baig
@kbaig
May 01 2018 14:58 UTC
It starts with C
Then goes into Python/JS/HTML/CSS
I used to be comfortable with Python but it's been nothing but JS for a couple years now so I needed some lower level exposure
Christopher McCormack
@cmccormack
May 01 2018 15:00 UTC
Sounds like fun, self paced?
Kaz Baig
@kbaig
May 01 2018 15:01 UTC
Indeed
Comes with a 'more comfortable' and a 'less comfortable' track to be better suited to your skill level
I'm struggling with the more comfortable pset2 problem right now lol
Feeling stupid
Christopher McCormack
@cmccormack
May 01 2018 15:02 UTC
That can only be a good thing, right? It's a learning course, if you are feeling stumped it means you're probably going to benefit more out of it than if you breezed through
I remember taking the Harvard CS course (can't remember the number or where) right after finishing my CS bachelors, and I still felt like an idiot. The teachers have a way of breezing through concepts or code that would normally take me a few days to fully grasp.
Kaz Baig
@kbaig
May 01 2018 15:05 UTC
@cmccormack CS50 is Harvard's intro to CS so that may be what you did
Yeah I'm glad to be learning this early into an intro course
Christopher McCormack
@cmccormack
May 01 2018 15:06 UTC
Maybe but it only had Python. Not sure why it's not in my history - what site is it on?
Kaz Baig
@kbaig
May 01 2018 15:06 UTC
edx
Christopher McCormack
@cmccormack
May 01 2018 15:08 UTC
weird not in my history, maybe they purge after a few years
anyway it was a really good course
Loved how high the production value was too
@kbaig let us know how the course was when you're done
Kaz Baig
@kbaig
May 01 2018 15:17 UTC
The professor is absolutely amazing
I did Boston University's intro to CS course and that has nothing on this
The supplementary resources are also well done
Christopher McCormack
@cmccormack
May 01 2018 15:24 UTC
Sounds like fun, I may have to sign up when I have a bit more time soon, thanks for the endorsement @kbaig
Kaz Baig
@kbaig
May 01 2018 15:27 UTC
Pleasure
AnthonyTankHD
@AnthonyTankHD
May 01 2018 15:40 UTC
hey what up
Christopher McCormack
@cmccormack
May 01 2018 15:41 UTC
@AnthonyTankHD yo
AnthonyTankHD
@AnthonyTankHD
May 01 2018 15:42 UTC
and i am kind stuck on this one course i cant get passed
Kyle Holm
@thekholm80
May 01 2018 16:16 UTC
good morning, /help
Kaz Baig
@kbaig
May 01 2018 16:18 UTC
hiya
Kyle Holm
@thekholm80
May 01 2018 16:19 UTC
@kbaig i learned something awesome yesterday
i had been trying to use async / await in Array.map() || Array.reduce() but not getting the results i expected
generally [Promise, Promise, Promise ...]
then i discovered Promise.all() so very cool
jeezcalmdown
@jeezcalmdown
May 01 2018 16:20 UTC
Hello, everyone! How are you guys?
Kyle Holm
@thekholm80
May 01 2018 16:20 UTC
@jeezcalmdown :wave:
jeezcalmdown
@jeezcalmdown
May 01 2018 16:20 UTC
Hey @thekholm80!
Wassup, man?
Kaz Baig
@kbaig
May 01 2018 16:21 UTC
@thekholm80 yeah Promise.all is the shizz
Kyle Holm
@thekholm80
May 01 2018 16:21 UTC
@jeezcalmdown working :(
@kbaig very, very cool. i wish i'd have found it sooner
jeezcalmdown
@jeezcalmdown
May 01 2018 16:21 UTC
Oh, cool. I rejoined this code community after 2 years, and the nostalgia hit me pretty damn hard.
Kyle Holm
@thekholm80
May 01 2018 16:22 UTC
welcome back
jeezcalmdown
@jeezcalmdown
May 01 2018 16:22 UTC
So, this room is for general help, right? Nice nice.
Kaz Baig
@kbaig
May 01 2018 16:22 UTC
While you're at it ;)
Kyle Holm
@thekholm80
May 01 2018 16:23 UTC
@kbaig oh man, generators. i haven't waded into that pool yet
Kaz Baig
@kbaig
May 01 2018 16:25 UTC
@thekholm80 that's just background info. Scroll to the last code block
Kyle Holm
@thekholm80
May 01 2018 16:27 UTC
for await almost seems like cheating
Kaz Baig
@kbaig
May 01 2018 16:31 UTC
yeeaaah
Kyle Holm
@thekholm80
May 01 2018 16:34 UTC
@kbaig so wait, in that last example - how would you handle rejected promises? just stick it all in a try/catch block?
Kaz Baig
@kbaig
May 01 2018 16:44 UTC
@thekholm80 probs
Henry
@GitHub-Henry
May 01 2018 16:47 UTC
@thekholm80 catch()
new Promise(function(resolve, reject) {
  reject(new Error("Whoops!"));
}).catch(alert); // Error: Whoops!
Kyle Holm
@thekholm80
May 01 2018 16:50 UTC

@GitHub-Henry so in

async function main() {
    const syncIterable = [
        Promise.resolve('a'),
        Promise.resolve('b'),
    ];
    for await (const x of syncIterable) {
        console.log(x);
    }
}
main();

you're sticking the .catch() on the caller? or where?

the caller isn't returning a Promise, so you'd probably get an error
Henry
@GitHub-Henry
May 01 2018 16:53 UTC
seems like mixing async and promises. usually i do one or the other
Kyle Holm
@thekholm80
May 01 2018 16:54 UTC
async / await is the best way to handle promises
so clean & intuitive
Henry
@GitHub-Henry
May 01 2018 16:55 UTC
here's an example of how i typically use a promise
fetch('no-such-user.json') // (*)
  .then(response => response.json())
  .then(user => fetch(`https://api.github.com/users/${user.name}`)) // (**)
  .then(response => response.json())
  .catch(alert); // SyntaxError: Unexpected token < in JSON at position 0
Kyle Holm
@thekholm80
May 01 2018 16:55 UTC
promise chaining is so ugly though
Henry
@GitHub-Henry
May 01 2018 16:55 UTC
it seems that's how they were designed to be used
Kyle Holm
@thekholm80
May 01 2018 16:57 UTC
try {
  const response = await fetch('...');
  const user = await fetch('...');
} catch (err) { throw err; };
something like that, anyway
Henry
@GitHub-Henry
May 01 2018 16:58 UTC
I typically use like this
(async () => {
  try {
    let response = await fetch(url);
    let data = await response.json();
    render(data);
  }
  catch (err) {
    error(err);
  }
})();
Kyle Holm
@thekholm80
May 01 2018 16:59 UTC
there you go
you can chain a catch() onto each async method for more specific error handling and get rid of the try/catch block
Nazar
@IsaakNazar
May 01 2018 17:17 UTC
Hello beautiful Fcc campers :)
Kyle Holm
@thekholm80
May 01 2018 17:19 UTC
@IsaakNazar :wave:
May Kittens Devour Your Soul
@diomed
May 01 2018 17:19 UTC
@IsaakNazar hi sexy
oh, wait, wrong chatroom
Nazar
@IsaakNazar
May 01 2018 17:21 UTC
fccIsSexy
Kitty :smile:
diomed @diomed gets on roflcopter and heads out
Kaz Baig
@kbaig
May 01 2018 17:39 UTC
Anyone done Heap's permutation algorithm?
Kyle Holm
@thekholm80
May 01 2018 17:41 UTC
@kbaig i used it on one of the fCC algo challenges - i don't recall which one though i'd have to look
Kaz Baig
@kbaig
May 01 2018 17:41 UTC
@thekholm80 would be no repeats please
Kyle Holm
@thekholm80
May 01 2018 17:42 UTC
ah, right you are
Christopher McCormack
@cmccormack
May 01 2018 17:44 UTC
yeah I did too, just pasted it in HelpJavaScript
idris
@idris12
May 01 2018 18:39 UTC
Does anyone here know how to make a website that uses cookies cause i find it hard understanding how to add cookies to my site
Ene Catalin
@EneCatalin
May 01 2018 18:41 UTC
what language ?
idris
@idris12
May 01 2018 18:41 UTC
javascript
Ene Catalin
@EneCatalin
May 01 2018 18:43 UTC
@diomed
halp him
Kyle Holm
@thekholm80
May 01 2018 18:48 UTC
if you're using express, you just set the cookie in the response header and use cookie-parser to parse cookies out of the request header
const express = require('express');
const cookeParser = require('cookie-parser');

const app = express();

app.use(cookieParser());
app.get('/', (req, res) => {
  const cookieThatCameWithTheRequest = req.cookies;  // cookie parsed from req object by cookie-parser
  const cookieBeingSetInResponse = { message: "I'm a cookie" };
  res.cookie('nameOfTheCookie', cookieBeingSetInResponse); // setting new cookie in response header
  res.send('Set a cookie!'); // sending response
});
app.listen(3000);
idris
@idris12
May 01 2018 18:53 UTC
so heres what i want to do it been giving me such a headache for the past few days and it so fraustrating
its a school project
so I have two page the first is where my product is which is this one
phonesPNG.PNG
and my shopping cart page which is this
shoppingcart.PNG
i want to make it that when a user pressing add to cart from the phone page it makes a table that has
product qty price
Kyle Holm
@thekholm80
May 01 2018 18:58 UTC
do you have a back end for this project or is it all in the browser?
idris
@idris12
May 01 2018 18:59 UTC

and on the table

The phone image appears on the -- product
The qty appears on the ----qty
price appears ---Price

Then when a user refreshes the page anything in the shopping cart wont be gone because of cookies
Kyle Holm
@thekholm80
May 01 2018 19:00 UTC
idris
@idris12
May 01 2018 19:00 UTC
@thekholm80 He we havent learned any back end he wants us to use html css , bootstrap and javascript
Kyle Holm
@thekholm80
May 01 2018 19:01 UTC
you can't set cookies from the front end, you should look at local storage or session storage
idris
@idris12
May 01 2018 19:01 UTC
i have used html css and bootstrap for the design javascript is the main problem now
it works in a similar way but doesn't require a server
idris
@idris12
May 01 2018 19:02 UTC
@thekholm80 ooh my God so why in the world is he asking us to do that then when we cant set cookies from front end
Kyle Holm
@thekholm80
May 01 2018 19:03 UTC
public school?
idris
@idris12
May 01 2018 19:03 UTC
Its a community college
And also how do i go about the the add to cart button whats the best way to do that?
Kyle Holm
@thekholm80
May 01 2018 19:05 UTC
in psudocode:
function addToCart:
  get the value of the item being added
  check storage to see if any other items are in the cart
  update storage with new item in cart
oh well i'll be ... you can set cookies from inside the browser https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie
sorry i was wrong
May Kittens Devour Your Soul
@diomed
May 01 2018 19:10 UTC
­čÉÖ
Kyle Holm
@thekholm80
May 01 2018 19:11 UTC
is that a squid or a ghost with 3 legs?
idris
@idris12
May 01 2018 19:15 UTC
Thank you at @thekholm80 am gonna start and when i have any more questions i will let you know so the first step is the dynamic table
May Kittens Devour Your Soul
@diomed
May 01 2018 19:17 UTC
octopus
AnthonyTankHD
@AnthonyTankHD
May 01 2018 19:22 UTC

``` <link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">

<style>
.red-text {
color: red;
}

h2 {
font-family: Lobster, Monospace;
}

p {
font-size: 16px;
font-family: Monospace;
}

.thick-green-border {
border-color: green;
border-width: 10px;
border-style: solid;
border-radius: 50%;
}

.smaller-image {
width: 100px;
}
</style>

<h2 class="red-text">CatPhotoApp</h2>

<img class="smaller-image thick-green-border" src="https://bit.ly/fcc-relaxing-cat" alt="A cute orange cat lying on its back. ">

<p>Here's a <a href="http://freecatphotoapp.com/"> cat photo</a> for you to follow.</p>

<p class="red-text">Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>

<p class="red-text">Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>
```

can you help on this
May Kittens Devour Your Soul
@diomed
May 01 2018 19:51 UTC
@AnthonyTankHD what up?
anthonygallina1
@anthonygallina1
May 01 2018 20:04 UTC
:sparkles:
Gulsvi
@gulsvi
May 01 2018 20:37 UTC
:sparkles:
anthonygallina1
@anthonygallina1
May 01 2018 20:39 UTC
Yup GDP I think it is called has been on my mind for a while. Hows everybody dealing with that?
Kyle Holm
@thekholm80
May 01 2018 20:40 UTC
gross domestic product?
anthonygallina1
@anthonygallina1
May 01 2018 20:41 UTC
sorry doh on my part
No that one :point_up:
Just a example link
Trying to communicate the idea
gishy1
@gishy1
May 01 2018 21:23 UTC
hello world tweet button is not responding
made some changes to the code
i declared a global variable at the top
but still not responding
Gulsvi
@gulsvi
May 01 2018 21:32 UTC

@gishy1 you're missing a var in front of theAuthor;

var theQuote;
theAuthor;

There is also a string concatenation issue with the tweet link you have:

  $("#btn2").on("click", function() {
    window.open("https://twitter.com/intent/tweet?tweet=myQuotes[radNo]+" - "+quoted[radNo]");
  });

A refresher: https://www.freecodecamp.org/challenges/constructing-strings-with-variables

Also, should that be https://twitter.com/intent/tweet?text= instead of https://twitter.com/intent/tweet?tweet= ?
gishy1
@gishy1
May 01 2018 21:34 UTC
try it bro
\
its giving me an error
Gulsvi
@gulsvi
May 01 2018 21:46 UTC
@gishy1 See the /NaN at the end of that URL? It's because of your string concatenation issue - your code is subtracting +quoted[radNo]" from the rest of the string
a string - a string = NaN (Not a Number)
Practice this and you'll see where the error is: https://www.freecodecamp.org/challenges/constructing-strings-with-variables
gishy1
@gishy1
May 01 2018 21:47 UTC
ok
but i put in a string
Gulsvi
@gulsvi
May 01 2018 21:48 UTC
"hello" + "world" = "helloworld"
"hello" - "world" = NaN
gishy1
@gishy1
May 01 2018 21:55 UTC
i out it in a string like this "-"
does that still make it a subtruction?
subtraction
@gulsvi
gishy1
@gishy1
May 01 2018 22:02 UTC
its showing the tweet page now, but in the tweet box is showing this in the tweet box
myQuotes[radNo] quoted[radNo]
Mois├ęs Man
@moigithub
May 01 2018 22:02 UTC
put in several lines and u will see..
NOTE: variables should NOT be surrounded with quotes
and quotes should be in PAIRS (open / closing ) to delimit strings
"some string" 
+
myVariable1 
+
"another string"
+
myVariable2
gishy1
@gishy1
May 01 2018 22:04 UTC
@moigithub dont get you bro
put in several lines?
Mois├ęs Man
@moigithub
May 01 2018 22:04 UTC
IF u surround the variable with quotes.. then it will be treated as string
soo it wont be "evaluated"
this is part of ur code
"https://twitter.com/intent/tweet?tweet=myQuotes[radNo]+" - "+quoted[radNo]"
split on several lines.. so u can identify which is a string
and what part is a variable
strings MUST have a open and a closing quotation mark " or '
variables should NOT have any quotation mark
gishy1
@gishy1
May 01 2018 22:09 UTC
@moigithub yes understood but one of the quotations is part of the windows open syntax, no?
also i removed the"-"
have a look
Mois├ęs Man
@moigithub
May 01 2018 22:10 UTC
IF u understand how a string its defined.. open/closing quotation marks.. u will identify whats ur problem...
gishy1
@gishy1
May 01 2018 22:11 UTC
ok
@moigithub but have you had a second look at my code?
Mois├ęs Man
@moigithub
May 01 2018 22:13 UTC
again.. a string should have a OPEN quotation mark
a string content... and a CLOSING quotation mark
example " content "
if u have a variable XXX
var XXX = 123
and place it inside pairs of quotation mark it will be treated LITERALLY as a string.. NOT a variable
Gulsvi
@gulsvi
May 01 2018 22:13 UTC
 $("#btn2").on("click",function(){
   var url = // put your URL here and concatenate variables with "string" + variable + "another string"
   console.log(url); // check your console for the URL after you click #btn2
   window.open(url);
 });
^ this may help you debug it better