These are chat archives for FreeCodeCamp/Help

5th
Nov 2018
dyon gerwen
@fullstackinprogress_gitlab
Nov 05 2018 00:18

can also someone explain

const router = express.Router()

what is does and where and when it is used

andrea
@girlcodecrush
Nov 05 2018 00:27
@fmartin5 Hi Luc. The data is from APIs that I fetch from a local news portal site. The data set is an array of objects and the objects has properties like title, link, publishedDate, and so on. What i want to do is to get the links with “https: //news.naver.com/“ ONLY. Hence, because data is an array, i thought .filter() method would be the best fit. Body.items refers to the array that contains multiple objects within. For reference, I’m currently using expressJS, sequelize for backend.
dyon gerwen
@fullstackinprogress_gitlab
Nov 05 2018 00:28
@girlcodecrush can you help me explain what express.router() does and where and when it is used
Luc Martin
@fmartin5
Nov 05 2018 00:29
@girlcodecrush Ah, thank you for the reply and the explanations - did you make some progress with this problem since?
andrea
@girlcodecrush
Nov 05 2018 00:30
@fmartin5 Maybe you are right. When i turned on the server, I got an error that says “Type error: Cannot read property 'filter' of undefined” My code goes : request(options, (error, response, body) => {
// body.items = []
var naverNews = body.items.filter(function (item) {
return item.link === 'https://news.naver.com/';
});
@fmartin5 @fullstackinprogress_gitlab if (!error && response.statusCode === 200) {
console.log(
naverNews + 'router listening on port 3000'
// 'http://127.0.0.1:3000/search/news?query=검색어 router listening on port 3000!'
);
res.set({ 'content-type': 'application/json; charset=utf-8' }); // should set utf-8 in request!!
res.end(body);
} else {
res.status(response.statusCode).end();
console.log('error = ' + response.statusCode);
}
});
@fullstackinprogress_gitlab express.router() is used in app.js and router/index.js and some other files.
Luc Martin
@fmartin5
Nov 05 2018 00:33
What is request here ? Is it https://github.com/request/request ?
Jefferson
@jeffersonnnn
Nov 05 2018 00:34
ugh, i hate being a newbie with all the questions but my code just isn't working and i am tired of scratching my head. Can i get help, please? So i am trying to get my code to take input from an input tage, find the first non-reoccurring letter on click and print to a div but it just isn't working. Maybe another pair of eyes will see the issues therein. Here is the HTML skeleton and the JS file. Thank youuuu
HTML skeleton
<title>the-repeat-me-not app</title>
<body>
  <label for="">give me the string!</label><br><input type="textbox" id="textName"  onkeyup="allow(this)"></input><br>
  <button onclick="runCode()">here is where the magic happens!</button><br>
<div id="result"></div>
</body>


JS
// for preventing invalid input
function allow(thisInput) {
  thisInput.value = thisInput.value.split(/[^a-zA-Z ]/).join("");
}

//recieve input from textbox and print to div

function runCode() {
  var strName = document.getElementById("textName");
  var str = strName.value;

  for (var i = 0; i < str.length; i++) {
    if (str.indexOf(str.charAt(i)) == str.lastIndexOf(str.charAt(i))) {
      var huxtable = str.charAt(i);
      document.getElementById("result").innerText = huxtable;
    }
  }
}
andrea
@girlcodecrush
Nov 05 2018 00:35
@fmartin5 No. As a client, I send a GET request to use APIs from a local portal site.
Luc Martin
@fmartin5
Nov 05 2018 00:38
Can you insert a console.log(body) statement just at the beginning of the callback - maybe body is just a string which would explain why body.items.filter would throw
In that case you would have to parse the body to get an actual object, for example with JSON.parse(body)
tightcode
@tightcode
Nov 05 2018 00:39
Maybe before creating a coding bootcamp learn how to communicate?
Luc Martin
@fmartin5
Nov 05 2018 00:39
Communicating is hard ^^
Especially when not everybody is native English speaker
Jefferson
@jeffersonnnn
Nov 05 2018 00:40
help?
Luc Martin
@fmartin5
Nov 05 2018 00:43
@jeffersonnnn I'm looking into it
Jefferson
@jeffersonnnn
Nov 05 2018 00:44
@fmartin5 more than grateful. my eyes hurt already lool
Luc Martin
@fmartin5
Nov 05 2018 00:44
:laughing:
@jeffersonnnn because of the loop you will get the last non-reoccurring letter (if everything else works)
So you should exit from the loop after the first match
Jefferson
@jeffersonnnn
Nov 05 2018 00:50
@fmartin5 and what i need is the ~first~ non-recurring letter. If this is the only problem, then it is easy to solve. i just couldn't get the code to run in the first place. Funniest? It just did using my chrome debugger tools and just plain refused to - till just now - with my codepen
Luc Martin
@fmartin5
Nov 05 2018 00:50
I think the code will even just display the last character of the input string
Jefferson
@jeffersonnnn
Nov 05 2018 00:51
since i see my error now, i'll go address it. thank you @fmartin5 ++
Luc Martin
@fmartin5
Nov 05 2018 00:51
:)
Also to alleviate the strain on your eyes, I would use str[i] everywhere instead of str.charAt(i) :p
It is the same unless you want to support really old browsers
Jefferson
@jeffersonnnn
Nov 05 2018 00:55
@fmartin5 haha i see what you mean, and i thought to use the same , but i could be asked to run my code on IE or something equally neolithic :p
Luc Martin
@fmartin5
Nov 05 2018 00:55
Yea old IE didn't support string indexing lol
IE7 or maybe 6
Jefferson
@jeffersonnnn
Nov 05 2018 00:59
this is half the problem with front-end dev in my humble opinion. aggrandizing the disparities in web browsers, and plain getting them to function with new and better features. soon as i can, i'm transitioning to backend haha
oh and the other half of writing CSS
Luc Martin
@fmartin5
Nov 05 2018 01:10
@tightcode I guess you have to replace the = null; // :( string with a correct call to the getTeafunction
Binyamin Aron Green
@b3u
Nov 05 2018 01:10
app.use('/shop/:id', (req, res) => {
    db.collection('users').doc(req.params.id).get()
        .then(doc => res.json(doc.data()));
})
I'm using firestore for my database and node/express for the server-side. How do I pass the json from doc.data() so I can integrate it in my html?
Luc Martin
@fmartin5
Nov 05 2018 01:30
@b3u Someone like @cmccormack could probably help you with this - for my part I don't know I can just guess it has to do with res.render() and a template engine
tightcode
@tightcode
Nov 05 2018 01:59
thanks luc
Christopher McCormack
@cmccormack
Nov 05 2018 02:02
@b3u what is .doc on your collection?
is that how you interact with firestore?
tightcode
@tightcode
Nov 05 2018 02:07
pfft const tea4TeamFCC = getTea(40); // :(
Luc Martin
@fmartin5
Nov 05 2018 02:15
@tightcode That's a lot of tea
Binyamin Aron Green
@b3u
Nov 05 2018 02:28
@cmccormack yes. that means document with the id of req.params.id
Christopher McCormack
@cmccormack
Nov 05 2018 02:36
@b3u if you need to get it from the frontend you can use a fetch request to your backend and serve it, looks like you can just hit /shop/:id
fetch('/shop/1234').then(response => response.json()).then(json => console.log(json))
andrea
@girlcodecrush
Nov 05 2018 02:39
@fmartin5 Yeah. Correct! Body needs to be parsed actually - I didn’t catch that it is stringified. Thanks! :)
Luc Martin
@fmartin5
Nov 05 2018 02:40
Cool :)
Binyamin Aron Green
@b3u
Nov 05 2018 02:42
So if I wanted to setup a template html file and fill it dynamically with the contents of the json, I would just make two promises?
Christopher McCormack
@cmccormack
Nov 05 2018 02:44
like the two promises I made above or something else?
but yeah you should be able to render your template and pass your data
Binyamin Aron Green
@b3u
Nov 05 2018 02:46
Like this:
app.use('/shop/:id', (req, res) => {
    db.collection('users').doc(req.params.id).get()
        .then(doc => res.json(doc.data()));
    res.sendFile('template.html');
})
Christopher McCormack
@cmccormack
Nov 05 2018 02:47
nope can only res once
plus if you're using a template you want render, no?
Binyamin Aron Green
@b3u
Nov 05 2018 02:48
I template was as in template.html. not literally templates, because I haven't gotten into that yet.
Christopher McCormack
@cmccormack
Nov 05 2018 02:48
app.use('/shop/:id', (req, res) => {
    db.collection('users').doc(req.params.id).get()
        .then(doc => res.render('template', doc.data()));
})
ah
may just want to do a fetch from your index file to the endpoint to get the json, but you'll need two different endpoints, one to serve the index and the other to grab the json
I agree with that other guy in the other channel as well, don't use app.use, use something like app.get
Binyamin Aron Green
@b3u
Nov 05 2018 02:51
Okay. Is that the best way to do this without templates?
Christopher McCormack
@cmccormack
Nov 05 2018 02:52
to get the json?
Binyamin Aron Green
@b3u
Nov 05 2018 02:52
yes.
Christopher McCormack
@cmccormack
Nov 05 2018 02:52
that's what your backend api should do, serve data like that
best is up to whatever works best for you though
Binyamin Aron Green
@b3u
Nov 05 2018 02:53
ah. this is only my second backend project.
So what is render for? Template engines?
Christopher McCormack
@cmccormack
Nov 05 2018 02:55
yeah
Binyamin Aron Green
@b3u
Nov 05 2018 02:55
Sounds good. Thanks.
Christopher McCormack
@cmccormack
Nov 05 2018 02:55
template engines are actually easy to setup in express
understanding the language itself may be a bit harder
but shouldn't be too bad
Binyamin Aron Green
@b3u
Nov 05 2018 02:55
I'll have to check them out.
I'll just do this:
app.get('/api/:id', (req, res) => {
    db.collection('users').doc(req.params.id).get()
        .then(doc => res.json(doc.data()));
})
and fetch like you said
Christopher McCormack
@cmccormack
Nov 05 2018 02:59
yup that should work
doc.data() converts it to json?
Binyamin Aron Green
@b3u
Nov 05 2018 03:00
No, that reads the data from the query.
But it outputs json
kinopotato
@kinopotato
Nov 05 2018 04:32
Hello, can someone help me with my JS code? My loop/regex is skipping somehow


function steamrollArray(arr) {
  let regex = /\d/g;
let newArr = arr.toString()
            .replace(",,", ",")
            .replace("[object Object]", "{}").split(",");
console.log(newArr); //returns [ '1', '2', '3', '4', 'a', 'b', '1', '3', '4', '1', '{}', '3', '4' ]
for (let i = 0; i < newArr.length; i++){
  if (regex.test(newArr[i])){
    console.log(newArr[i]); // returns 1 3 1 4 3 (it skips some numbers)
  newArr[i] = Number(newArr[i]); //even when I remove this, only 1 3 1 4 3 still returns which means it's not a problem with mutating the array
  }
}
return newArr; //[ 1, '2', 3, '4', 'a', 'b', 1, '3', 4, '1', '{}', 3, '4' ]
}

steamrollArray([1, [2], [3, [[4]]], [[["a"]], [["b"]]], [1, [], [3, [[4]]]], [1, {}, [3, [[4]]]]]);
in the end, the numbers should return into numbers and the string be left alone, but as you can see, 2, 4 and well it basically skips a number
Aditya
@ezioda004
Nov 05 2018 04:52
If you need to use the internal class of an object ie [object Object], you might wanna rethink your approach.
kinopotato
@kinopotato
Nov 05 2018 04:53
it's working so far though? I mean the problem isn't there right?
Aditya
@ezioda004
Nov 05 2018 04:55
Its a hacky solution, it may work but should be avoided if possible.
Since you need to flatten the array, you can think of maybe using a while loop/recursion.
kinopotato
@kinopotato
Nov 05 2018 04:57
that makes sense, but for now I want to finish this and once it works, I'll see how FCC does it and study that. I mean that approach also makes sense right? If I abandon this code, I won't learn why it's not working.
Aditya
@ezioda004
Nov 05 2018 05:00
True, so the output should be [1, 2, 3, 4, "a", "b", 1, 3, 4, 1, "{}", 3, 4] right?
kinopotato
@kinopotato
Nov 05 2018 05:00
yes, but the matching is skipping. I logged the loop and it was doing a steady 0 to 11 (12 is the length) so nothing wrong with the length or how many times it loops
Aditya
@ezioda004
Nov 05 2018 05:03
Remove the g flag, and it should work.
Luc Martin
@fmartin5
Nov 05 2018 05:03
@kinopotato Lines like .replace(",,", ",") will only replace the first occurence found, is this what you intended?
kinopotato
@kinopotato
Nov 05 2018 05:05
@fmartin5 as Ezioda said, this is a hacky code, I absolutely have no idea what is happening
@ezioda004 it does O.O but why?? if it's matching only a single number, then the g shouldn't matter, if it's matching multiple numbers, then it should be there. how is it making my code not work??
Luc Martin
@fmartin5
Nov 05 2018 05:08
wtf
Node.js> re =/\d/g
/\d/g
Node.js> re.test("4")
true
Node.js> re.test("4")
false
Aditya
@ezioda004
Nov 05 2018 05:08
Thats because how .test() works, subsequent searches on the same string with .test() will use the next index automatically.
Luc Martin
@fmartin5
Nov 05 2018 05:09
I didn't know that
Very unintuitive ^^
Aditya
@ezioda004
Nov 05 2018 05:09
Yep, me neither sometime ago. It was a gotcha.
kinopotato
@kinopotato
Nov 05 2018 05:09
well at least you learn some low level shit when you do hacky coding xD
Luc Martin
@fmartin5
Nov 05 2018 05:09
:D
kinopotato
@kinopotato
Nov 05 2018 05:10
Now I need to turn "{}" into whatever this is {}
Aditya
@ezioda004
Nov 05 2018 05:10
@kinopotato Your code doesnt handle string numbers - Example ["1", "2"]
Luc Martin
@fmartin5
Nov 05 2018 05:11
JSON.parse ? @kinopotato
kinopotato
@kinopotato
Nov 05 2018 05:11
it worked though with the numbers
@fmartin5 I still have no clue wtf json is, and since it has the same name as the horror movie murderer, I'm not keen on knowing him just yet
Luc Martin
@fmartin5
Nov 05 2018 05:12
haha
kinopotato
@kinopotato
Nov 05 2018 05:12
it's weird but I just work this way, I do the hacky code since it's what comes to mind then I study the FCC code,
then try to find the middle ground that I can consistently do since I'm still a beginner
Luc Martin
@fmartin5
Nov 05 2018 05:13
Usually people learn the hacky ways last x)
kinopotato
@kinopotato
Nov 05 2018 05:13
not when you're an idiot 8D
Aditya
@ezioda004
Nov 05 2018 05:13
It does work with number because .toString() removes the "primitiveness".
[1, 2].toString(); // "1,2"
["1", "2"].toString(); // "1,2"
Luc Martin
@fmartin5
Nov 05 2018 05:14
@kinopotato No that's because you try hard to solve the problem with what you know
kinopotato
@kinopotato
Nov 05 2018 05:14
there must be a way to finish this challenge with the code I have started xD I need the {}
@luc
@fmartin5 which isn't much 8D at the moment
Luc Martin
@fmartin5
Nov 05 2018 05:15
You could iterate over the array and replace every "{}" with a new Object
kinopotato
@kinopotato
Nov 05 2018 05:15
maybe I can splice this or something
Luc Martin
@fmartin5
Nov 05 2018 05:16
Oh no, no splice x)
kinopotato
@kinopotato
Nov 05 2018 05:16
I miss doing basic javascript, you do alert ("hello world") and you feel like a master hacker
Luc Martin
@fmartin5
Nov 05 2018 05:16
=)
Aditya
@ezioda004
Nov 05 2018 05:20
This is how I'd solve it:
function steamrollArray(arr){
  return arr.reduce((a, c) => Array.isArray(c) ? a.concat(steamrollArray(c)) : a.concat(c), []);
}
steamrollArray([1, [2], [3, [[4]]], [[["a"]], [["b"]]], [1, [], [3, [[4]]]], [1, {}, [3, [[4]]]]]); // [1, 2, 3, 4, "a", "b", 1, 3, 4, 1, {…}, 3, 4]
kinopotato
@kinopotato
Nov 05 2018 05:21
anything with => is still driving me insane xD
Luc Martin
@fmartin5
Nov 05 2018 05:21
I think this is a big spoiler
kinopotato
@kinopotato
Nov 05 2018 05:21
only if you understand it 8D
Luc Martin
@fmartin5
Nov 05 2018 05:22
xD
kinopotato
@kinopotato
Nov 05 2018 05:22
in my case, it will take at least 5 minutes to register wth is happening
Luc Martin
@fmartin5
Nov 05 2018 05:23
It took me way more than 5 minutes to understand reduce
kinopotato
@kinopotato
Nov 05 2018 05:23
@ezioda004 I see you used a question mark "?", interesting, since that's exactly how I feel when I see this code
@fmartin5 yep, I'm taking it back, this will take a whole day at least
Aditya
@ezioda004
Nov 05 2018 05:24
@kinopotato Lol, its a ternary operator - equivalent of if..else statements.
Claudio Restifo
@Marmiz
Nov 05 2018 05:24

@ezioda004

[].concat(...arr.map(v => (Array.isArray(v) ? flat(v) : v)));

this is what I have.
Same, but recursive instead of reducing

i was into recusrsion at that time
kinopotato
@kinopotato
Nov 05 2018 05:25
I can only use recursion to add things .__.
Claudio Restifo
@Marmiz
Nov 05 2018 05:25
this is what is actually doing this thin
adding v value seen from map :)
unless v is an array, in this case calls itself again :)
Aditya
@ezioda004
Nov 05 2018 05:27
@Marmiz Aha, with the new .flat() method you can simply use that:
[1, [2], [3, [[4]]], [[["a"]], [["b"]]], [1, [], [3, [[4]]]], [1, {}, [3, [[4]]]]].flat(Infinity);
// [1, 2, 3, 4, "a", "b", 1, 3, 4, 1, {…}, 3, 4]
kinopotato
@kinopotato
Nov 05 2018 05:27
which means I can just use this???
Claudio Restifo
@Marmiz
Nov 05 2018 05:27
@ezioda004 there's a flat method?
kinopotato
@kinopotato
Nov 05 2018 05:28
oh no, it's not working xD
I thought there's a miracle
Aditya
@ezioda004
Nov 05 2018 05:28
@kinopotato You shouldnt, otherwise you wont learn the basics.
@Marmiz Yes, its a stage 3 proposal
Works on chrome with experimental settings on
kinopotato
@kinopotato
Nov 05 2018 05:29
fuck the basics! I want to be able to pretend to be just good enough to land a job 8D hahaha, I'm desperate. I feel like JS hates me in particular
Aditya
@ezioda004
Nov 05 2018 05:30
I get that, it gets hard but honestly you shouldnt cut corners, otherwise eventually it'll come back to haunt you.
kinopotato
@kinopotato
Nov 05 2018 05:30
yes but think of it this way, when it haunts me, it's haunting me while I'm being paid 8D hahahaha
sorry, I've been working on this thing since morning
Claudio Restifo
@Marmiz
Nov 05 2018 05:33

@kinopotato look. I can write "fluently" in JS, but now at work I have to make some API in php.
I write it like a 3rd grader would write a letter to Santa.

It's normal.
There's no shortcut.

@ezioda004 i don't fiddle much with experimental feature. Am I missing something cool?
kinopotato
@kinopotato
Nov 05 2018 05:35
@Marmiz exactly, you are being paid to write like a 3rd grader to santa. hahaha, nah I'm just kidding. Yes I agree completely, I want to master JS basics. right now though I just want to turn this "{}" into this {}
Claudio Restifo
@Marmiz
Nov 05 2018 05:36

you are being paid to write like a 3rd grader to santa

I am (also) getting paid...
subtle, but that's the difference :tongue:

Aditya
@ezioda004
Nov 05 2018 05:36
@Marmiz We have more class features if you're into that (static, private fields and methods). In particular I'm excited for dynamic imports (stage 3 proposal), basically you can import stuff based on conditions.
Claudio Restifo
@Marmiz
Nov 05 2018 05:37
@ezioda004 i'd be excited if import actually become compatible.
Aditya
@ezioda004
Nov 05 2018 05:38
@kinopotato You can use JSON.parse("{}")// {}
@Marmiz Thats supported by all browsers now, init?
Claudio Restifo
@Marmiz
Nov 05 2018 05:38
@ezioda004 new one. I still need commonJS and require
kinopotato
@kinopotato
Nov 05 2018 05:44
does json.parse(var[index]) work? is this syntax supposed to work?
kinopotato
@kinopotato
Nov 05 2018 05:53
@ezioda004 may I ask how did you master or at the least learn higher order functions? I keep forgetting them for some reason. I was able to finish the code but I really do admit my code sucks.
Aditya
@ezioda004
Nov 05 2018 05:57
@kinopotato Start with learning how .forEach(), .map(), .filter() and .reduce() works. If possible do the functional programming section in fcc and sovle few problems on codewars to get comfortable with using HOFs.
After that try to implement your own .map() and other higher order functions.
kinopotato
@kinopotato
Nov 05 2018 06:05
@ezioda004 I've done the functional programming xD I keep forgetting things that I've learned. But if you mean codewars.com then I'll check this once I finish my FCC JS for mastery while also learning DOM manipulation. That course of action isn't half bad right? I do want to be a front end web developer
Aditya
@ezioda004
Nov 05 2018 06:09
@kinopotato Thats fine - initially what helped me retain was starting to think about using HOFs in any problem I was solving. Example: If I need to use a for loop then I'd try to use .forEach() instead. If I need to loop through an array then I'd try to think of solving it with .map() and so on. Since all of this is declarative - it takes a bit more time getting used to.
kinopotato
@kinopotato
Nov 05 2018 06:11
I thought declarative was supposed to be bad?
Aditya
@ezioda004
Nov 05 2018 06:33
No? Its an added abstraction over imitativeness. For the most part its easier to write and increases readability of the program.
kinopotato
@kinopotato
Nov 05 2018 08:22

So I just did this without knowing about charcode



function binaryAgent(str) {

  return str
            .replace(/01000001/g, "A")
            .replace(/01100001/g, "a")
            .replace(/01000010/g, "B")
            .replace(/01100010/g, "b")
            .replace(/01000011/g, "C")
            .replace(/01100011/g, "c")
            .replace(/01000100/g, "D")
            .replace(/01100100/g, "d")
            .replace(/01000101/g, "E")
            .replace(/01100101/g, "e")
            .replace(/01000110/g, "F")
            .replace(/01100110/g, "f")
            .replace(/01000111/g, "G")
            .replace(/01100111/g, "g")
            .replace(/01001000/g, "H")
            .replace(/01101000/g, "h")
            .replace(/01001001/g, "I")
            .replace(/01101001/g, "i")
            .replace(/01001010/g, "J")
            .replace(/01101010/g, "j")
            .replace(/01001011/g, "K")
            .replace(/01101011/g, "k")
            .replace(/01001100/g, "L")
            .replace(/01101100/g, "l")
            .replace(/01001101/g, "M")
            .replace(/01101101/g, "m")
            .replace(/01001110/g, "N")
            .replace(/01101110/g, "n")
            .replace(/01001111/g, "O")
            .replace(/01101111/g, "o")
            .replace(/01010000/g, "P")
            .replace(/01110000/g, "p")
            .replace(/01010001/g, "Q")
            .replace(/01110001/g, "q")
            .replace(/01010010/g, "R")
            .replace(/01110010/g, "r")
            .replace(/01010011/g, "S")
            .replace(/01110011/g, "s")
            .replace(/01010100/g, "T")
            .replace(/01110100/g, "t")
            .replace(/01010101/g, "U")
            .replace(/01110101/g, "u")
            .replace(/01010110/g, "V")
            .replace(/01110110/g, "v")
            .replace(/01010111/g, "W")
            .replace(/01110111/g, "w")
            .replace(/01011000/g, "X")
            .replace(/01111000/g, "x")
            .replace(/01011001/g, "Y")
            .replace(/01111001/g, "y")
            .replace(/01011010/g, "Z")
            .replace(/01111010/g, "z")
            .replace(/00100001/g, "!")
            .replace(/00111111/g, "?")
            .replace(/00100111/g, "'")
            .replace(/\s/g, "")
            .replace(/00100000/g, " ");
}

binaryAgent("01000001 01110010 01100101 01101110 00100111 01110100 00100000 01100010 01101111 01101110 01100110 01101001 01110010 01100101 01110011 00100000 01100110 01110101 01101110 00100001 00111111");

welp, time to learn about charcode

Josaped Moreno
@androuino
Nov 05 2018 08:37

Hi, could I ask for help with my web development in Angular? I am doing a search engine functionality with my website, and I want my search function to search only the texts/divs inside my web page. What I have so far is this

var app = angular.module('app', []);
app.controller("body-controller", function ($scope, $http) {
     // Submit
    $scope.submit = function () {
        $scope.loading = true;
        $scope.error = false;
        $http.get('http://www.google.com/?t=' + $scope.search + '&y=&plot=full&r=json')
               .success(function (data, status, headers, config) {
                   $scope.data = data;
                   $scope.results = true;
                   $scope.error = false;
                   $scope.loading = false;

                   if ($scope.data.Poster === "N/A") {
                       $scope.data.Poster = "http://placehold.it/350x450/FFF/EEE";
                   }

                   if ($scope.data.Response === "False") {
                       $scope.results = false;
                       $scope.error = true;
                   }
               })
               .error(function (data, status, headers, config) {
                   $scope.results = false;
                   $scope.loading = false;
                   $scope.error = true;
               });
    };

    $scope.saveData = function (imdbID) {
        $http.get(' http://www.google.com/?i=' + id + '&plot=short&r=json')
         .success(function (data, status, headers, config) {
             $scope.savedData.push(data);
         });
    };

    $scope.remove = function (item) {
        var index = $scope.savedData.indexOf(item)
        $scope.savedData.splice(index, 1);
    }

    $scope.savedMovies = [];
});

Could anyone please guide me on what to change in order to achieve what I want? Thanks, you're appreciated.

Ghost
@ghost~5b53da7dd73408ce4fa1d2e5
Nov 05 2018 08:42
Hi guys I'm having problem with the Advanced Node and Express - Registration of New Users and I posted here also the question https://www.freecodecamp.org/forum/t/registration-of-new-users/238130. I hope there's someone can help me with this.
Pandaliu
@PandaLiun
Nov 05 2018 11:17
Who can tell me how to do HTML eighteenth?
image.png
May Kittens Devour Your Soul
@diomed
Nov 05 2018 12:09
@PandaLiun style tags should not be written multiple times
all your classes with their properties should go between first set of style tags. [that's the only set you need]
May Kittens Devour Your Soul
@diomed
Nov 05 2018 12:17
marlene on the wall :musical_note:
andrea
@girlcodecrush
Nov 05 2018 12:46
Does anybody know about auto player function with ReactJS? What I’ve been trying to do is to get news articles to be played when onclickEvent is done to each of the headlines on the articles list. The audio player is located on the bottom of the page.
Anand Potukuchi
@anandpotukchi
Nov 05 2018 12:52
@girlcodecrush can you please share the relavent code
Xarri Jorge
@xarrijorge
Nov 05 2018 13:52
:wave:
Anand Potukuchi
@anandpotukchi
Nov 05 2018 14:21
@xarrijorge :wave:
@girlcodecrush are you still there?
Daniel Simeonov
@dbsimeonov
Nov 05 2018 14:59
guys do i need to upload chunk-vendor from vue to deploy the webpage, as one of the pluggins doesn’t seem to work on my page, and there is no other reason I can think of
Victor Popescu
@VicPopescu
Nov 05 2018 15:25
this._grandma.pipe(takeWhile(() => !this.bellyFull)).subscribe(potatos => {
            this.belly.push(...potatos);
            this.bellyFull = this.belly.length > 9000 ? true : false;
});
hmm or a private vomit(): Array<Potato> would be a better idea to refactor this
May Kittens Devour Your Soul
@diomed
Nov 05 2018 17:20
this looks like grandma is a pot smoker
Christopher McCormack
@cmccormack
Nov 05 2018 17:23
@diomed lol
Luc Martin
@fmartin5
Nov 05 2018 17:24
hello
May Kittens Devour Your Soul
@diomed
Nov 05 2018 17:26
hello :fox:
I demand to know who's responsible for gitter emoji integration - RIGHT NOW!
Luc Martin
@fmartin5
Nov 05 2018 17:27
:laughing:
yeah no fox emoji :'(
May Kittens Devour Your Soul
@diomed
Nov 05 2018 17:28
so sad
Nicolas Ramirez
@kamatheuska
Nov 05 2018 17:55
Anyone would happen to know how to do mongoDB scheme validation without mongoose? an example project would be enough!
Bashaar (Bas)
@Chiefbas
Nov 05 2018 17:57
Heyy! I've noticed that the challanges have expended rapidly. How long did it take for you guys to finish web design section?
Niraj Nandish
@Nirajn2311
Nov 05 2018 17:57
@diomed fox emoji = 🦊
Bashaar (Bas)
@Chiefbas
Nov 05 2018 18:11
Someone?
Luc Martin
@fmartin5
Nov 05 2018 18:15
I am doing the new challenges
So I have no idea how long it will take :laughing:
Bashaar (Bas)
@Chiefbas
Nov 05 2018 18:17
It's legit a lot. Wish i could go back to the previous challenges....😢
Bashaar (Bas)
@Chiefbas
Nov 05 2018 18:31
But we have to fight hard to become a full stack
Tom
@moT01
Nov 05 2018 19:02
@Chiefbas most, if not all of the old challenges are in the new curriculum somewhere - just maybe in different areas
Christopher McCormack
@cmccormack
Nov 05 2018 19:06
Don't look in the interview prep section :)
Niraj Nandish
@Nirajn2311
Nov 05 2018 19:09
@cmccormack why, is theree too much
Christopher McCormack
@cmccormack
Nov 05 2018 19:14
@Nirajn2311 it's all the exercises from project euler, rosetta code, etc..
so yeah lots :)
plus a lot of the legacy projects are in there + some new ones
Eric Miller
@ericmiller777
Nov 05 2018 20:45
hey
I have
const squaredIntegers = arr.filter(evenNotZero => evenNotZero % 2 == 0 && evenNotZero > 0);
and
console.log(arr.map(add => add = Math.pow(add, 2)));
how do i combine the two
so that only the filtered are mapped (returned squared)
@daddycardona hey man, glad to see you I thought the channel was erased.
Xarri Jorge
@xarrijorge
Nov 05 2018 20:56
chaining the methods should work. i.e, the value returned from filter gets passed into map and squared
@ericmiller777
const squaredIntegers = arr.filter(logic here).map(v => v**2); @ericmiller777
Binyamin Aron Green
@b3u
Nov 05 2018 21:19
Hey 'yall, got a question for you.
I'm designing a full-stack web app, and IMHO it looks like <insert your favorite expletive>. Here is a link to it. Can someone give me some pointers so it looks more on the level of this? Thanks.
Xarri Jorge
@xarrijorge
Nov 05 2018 21:37
First off, why do you have scroll past end enabled? @b3u
Binyamin Aron Green
@b3u
Nov 05 2018 21:37
huh?
Xarri Jorge
@xarrijorge
Nov 05 2018 21:38
The page scrolls to absurd distance when no content is available
Binyamin Aron Green
@b3u
Nov 05 2018 21:38
on the preview mode?
Xarri Jorge
@xarrijorge
Nov 05 2018 21:39
Yep, I'm scrolling to acres of whitespace
Binyamin Aron Green
@b3u
Nov 05 2018 21:39
huh. I'll try to recreate it. On which page.
Xarri Jorge
@xarrijorge
Nov 05 2018 21:39
If its React and you want help just add the repo link here
Binyamin Aron Green
@b3u
Nov 05 2018 21:40
Its not react. : {
But I do have a repo link
Xarri Jorge
@xarrijorge
Nov 05 2018 21:43
okay, drop it and we can take a look
Binyamin Aron Green
@b3u
Nov 05 2018 21:43
It's on bitbucket currently. Will probably change to github. I need to upload the changes first either way.
Also, code's not finished.
Xarri Jorge
@xarrijorge
Nov 05 2018 21:47
Access Denied!
Binyamin Aron Green
@b3u
Nov 05 2018 21:47
Argh. Hold on.
Try now.
Xarri Jorge
@xarrijorge
Nov 05 2018 21:48
:thumbsup:
You're using firebase as DB?
and Auth?
Binyamin Aron Green
@b3u
Nov 05 2018 21:50
Yup. That's what I'm most comfortable with. no auth.
Why?
Xarri Jorge
@xarrijorge
Nov 05 2018 21:55
No reason. I've used it in a tutorial project but now I'm learning MongoDB
so basically, you want the cards to look like they do on the yelp camp site right?
Binyamin Aron Green
@b3u
Nov 05 2018 21:56
Well the whole interface, really. The banner, navbar, etc.
Xarri Jorge
@xarrijorge
Nov 05 2018 21:57
What is the app suppose to do?
Binyamin Aron Green
@b3u
Nov 05 2018 21:58
Should probably put that in the readme/description.
Xarri Jorge
@xarrijorge
Nov 05 2018 21:58
Yeah, cuz I'm logged in but don
don't have slightest idea what's going on
Binyamin Aron Green
@b3u
Nov 05 2018 21:59
It's a cat shop, But you can add a cat.
Xarri Jorge
@xarrijorge
Nov 05 2018 21:59
Or what I'm to be doing?
to buy and sell cats?
Binyamin Aron Green
@b3u
Nov 05 2018 21:59
That's probably a problem with the ui straight away.
Xarri Jorge
@xarrijorge
Nov 05 2018 22:00
Okay so whats with the code viewer in the right sidebar? it looks more like a photo editor or some graphic app to me
Binyamin Aron Green
@b3u
Nov 05 2018 22:01
Well, I'm not sure about the purpose. I really just wanted an app that would get and post data. That way I would learn db better.
Xarri Jorge
@xarrijorge
Nov 05 2018 22:01
Okay, now I see. :smile:
Firebase abstracts a lot so if you want to learn real DB try using a SQL(fam) or MongoDB
Binyamin Aron Green
@b3u
Nov 05 2018 22:02
Sounds good.
Xarri Jorge
@xarrijorge
Nov 05 2018 22:03
Cuz firebase functions are all unique and can't be brought to another framework
Binyamin Aron Green
@b3u
Nov 05 2018 22:03
oh.
Xarri Jorge
@xarrijorge
Nov 05 2018 22:04
Yeah, its kinda like React/Angular/Vue, you'll have to relearn the syntax/methods of every new framework. But languages like SQL and MongoDB are base level
Binyamin Aron Green
@b3u
Nov 05 2018 22:05
You're saying firebase doesn't integrate well with something like react?
Xarri Jorge
@xarrijorge
Nov 05 2018 22:05
Nope, it does, very well I might add.
Binyamin Aron Green
@b3u
Nov 05 2018 22:06
So it's just much different than, say, mongoDB.
Xarri Jorge
@xarrijorge
Nov 05 2018 22:07
I'm saying if your goal is to learn the underlying DB technology, firebase is not your best option. its like learning when you want to learn code. First you should start with JS/Python or some base level language before moving on to a framework
Binyamin Aron Green
@b3u
Nov 05 2018 22:07
okay. Now I got it.
Xarri Jorge
@xarrijorge
Nov 05 2018 22:08
Yeah, cuz frames abstract a lot. And you want to get as much understanding of the tech as possible when learning. You can then specialize or pick a preference when you know what makes them different
Anyways, I'll take a look and see if I can help improve the styling/layout
Binyamin Aron Green
@b3u
Nov 05 2018 22:09
Thanks.
Jacky Lui
@Recelis
Nov 05 2018 22:10
Hi, I made my first pull request to modify a guide on FCC, and some people asked me to make some changes to my PR. How exactly do I do this? Do I make a new PR or is there a way to edit the current request?
Binyamin Aron Green
@b3u
Nov 05 2018 22:11
You edit the branch and then comment you've made the changes.
dyon gerwen
@fullstackinprogress_gitlab
Nov 05 2018 22:14
please tell me what are the node.js & express modules you need to master (the must haves ) before i can call me a node.js/express developer
Jacky Lui
@Recelis
Nov 05 2018 22:26
where are you at with node/express programming @fullstackinprogress_gitlab ?
also thanks @b3u , just sent it in.
dyon gerwen
@fullstackinprogress_gitlab
Nov 05 2018 22:27
@Recelis i can make forms on the moment but now learning about validation
with express-validator
very basic on the moment
Jacky Lui
@Recelis
Nov 05 2018 22:49
hmmm you are ahead of me then.
Binyamin Aron Green
@b3u
Nov 05 2018 22:59
@Recelis Can you give me some advice?
Jacky Lui
@Recelis
Nov 05 2018 23:01
Oops! the page doesn't exist or is private
Binyamin Aron Green
@b3u
Nov 05 2018 23:02
Try now.