These are chat archives for FreeCodeCamp/HelpJavaScript

15th
Apr 2018
Mel Macaluso
@MelMacaluso
Apr 15 2018 01:51
    performSearch () {
      console.log('pre-debounce')
      _.debounce((e) => {
        console.log('intra-debounce')
        axios.get('https://www.googleapis.com/youtube/v3/search?maxResults=9&part=snippet&q=' + this.query + '&key=' + process.env.YOUTUBE_API_KEY)
        .then((response) => {
          this.searchResults = response.data.items
          console.log(this.searchResults)
        })
        .catch(function (error) {
          console.log(error)
        })
      }, 666)
      console.log('post-debounce')
    }
any guru that enlightens me why I can't make the "intra-debounce" part work on keyup on my input text v-model?
without the debounce it works just fine
Stephen James
@sjames1958gm
Apr 15 2018 02:03
@MelMacaluso What behavior are you seeing?
Mel Macaluso
@MelMacaluso
Apr 15 2018 02:04
Nothing unfournately, on the other thread I mentioned that I converted it like so for now and it kind of works:
    performSearch:
      _.debounce((e) => {
        axios.get('https://www.googleapis.com/youtube/v3/search?maxResults=9&part=snippet&q=' + this.query + '&key=' + process.env.YOUTUBE_API_KEY)
        .then((response) => {
          this.searchResults = response.data.items
          console.log(this.searchResults)
        })
        .catch(function (error) {
          console.log(error)
        })
      }, 666)
it now debounces and returns the console.log of the response but doesn't display the results in the page :joy:
also it stays a mistery to me why I had to convert it like that to make it work
Stephen James
@sjames1958gm
Apr 15 2018 02:06
Is it possible that you have the wrong this ? Perhaps console.log(this) and see what it is
Mel Macaluso
@MelMacaluso
Apr 15 2018 02:07
Had to convert it to non-arrow to make it work...
stays very unclear "do you have any idea why performSearch() doesn't debounce (my first snippet) and the other (last one performSearch:) actually does?"
That's a thought one :smirk:
Pieter Stokkink
@forkerino
Apr 15 2018 08:31
@MelMacaluso debounce returns a function
Markus Kiili
@Masd925
Apr 15 2018 08:50
@forkerino Morning.
Pieter Stokkink
@forkerino
Apr 15 2018 08:54
@Masd925 hello!
Markus Kiili
@Masd925
Apr 15 2018 09:05
@forkerino How is the solar business going?
Pieter Stokkink
@forkerino
Apr 15 2018 09:17
@Masd925 it's booming! We're going to expand to other countries, which brings a lot of interesting problems to work on.
How's life?
Markus Kiili
@Masd925
Apr 15 2018 09:19
@forkerino Wife finally got out of the hospital so getting better. I won the breath holding in the nationals, so that was nice. Could go to the world championships, but would be just an expensive tourist trip with my current shape.
How about you?
Learning clojure for the new job is fun.
Derrick Hsiao
@DerrickHsiao
Apr 15 2018 09:39
Help me pass this challeng
I'm taiwaness, my english is very bad :worried:
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";
  // 请把你的代码写在这条注释以下


  // 请把你的代码写在这条注释以上
  return result;
}

wordBlanks("dog", "big", "ran", "quickly");  // 你可以修改这一行来测试你的代码
Markus Kiili
@Masd925
Apr 15 2018 09:41
@DerrickHsiao Those parameters myNoun etc. hold the passed words from the function call. You need to use the parameters and string operations and construct a long sentence and assign it to var result.
Derrick Hsiao
@DerrickHsiao
Apr 15 2018 09:42
@Masd925 How can I assign it to var result?
Markus Kiili
@Masd925
Apr 15 2018 09:53
@DerrickHsiao Use the assignment operator =.
var result = ...
Derrick Hsiao
@DerrickHsiao
Apr 15 2018 10:00
@Masd925 Thank a lot!
CamperBot
@camperbot
Apr 15 2018 10:00
derrickhsiao sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4778 | @masd925 |http://www.freecodecamp.org/masd925
Derrick Hsiao
@DerrickHsiao
Apr 15 2018 14:33
Where's issue?
// 举例
function ourFunction(a, b) {
  console.log(a - b);
}
ourFunction(10, 5); // 输出 5

// 请把你的代码写在这条注释以下
function myFunction() {
  console.log(1 + 2, 7 + 9);
}
myFunction(3, 16);
Moisés Man
@moigithub
Apr 15 2018 14:59
ourFunction have (a,b ) parameters....
which will hold the values (10,5) u pass when call/execute the function @DerrickHsiao
Pieter Stokkink
@forkerino
Apr 15 2018 17:10
@Masd925 Sounds like nice developments, cool that you are working with clojure now!
nathyjegs
@nathyjegs
Apr 15 2018 17:19
Hello there
Can anyone please help me solve this problem
Write a function my_sort which takes in a list of numbers (integers).
The function should return a list of sorted numbers such that odd numbers come first and even numbers
come las
Markus Kiili
@Masd925
Apr 15 2018 17:27
@nathyjegs What language are you using (javascript doesn't have lists)?
nathyjegs
@nathyjegs
Apr 15 2018 17:28
@Masd925 Arrays rather
Markus Kiili
@Masd925
Apr 15 2018 17:29
@nathyjegs You can use the .sort() method with a suitable callback function.
nathyjegs
@nathyjegs
Apr 15 2018 17:29
I don't know how to go about it
Markus Kiili
@Masd925
Apr 15 2018 17:33
@nathyjegs You need to pass a callback function function(a,b){return ...} to sort method that defines the sorting you need. Those a and b will hold some elements from your array (numbers). You need to make the return value so that the return value is negative if a should come before b. For example return a-b would produce ascending order.
Because if for example 5 and 2 are passed, a-b will be 3 and the order will be switched.
nathyjegs
@nathyjegs
Apr 15 2018 17:39
thanks
1Mher1
@1Mher1
Apr 15 2018 18:13
We have a input where the number will be recorded. There is a selection of pictures from here, such as Cat, Dog, Elephant .... When pressing the ADD button, the corresponding number of images should be added to the screen.
please help me to do this chellange
Pieter Stokkink
@forkerino
Apr 15 2018 18:31
@tiagocorreiaalmeida ha, next time I'll try to join at the start, so we can have a fair fight!
Tiago Correia
@tiagocorreiaalmeida
Apr 15 2018 18:36
@forkerino indeed, how much did it take you tough?was having fun with my brother
Pieter Stokkink
@forkerino
Apr 15 2018 18:37
@1Mher1 You can add src to an option, but it doesn't turn it into an image.
@tiagocorreiaalmeida I dunno, couple minutes
haven't done a lot of codefights
Tiago Correia
@tiagocorreiaalmeida
Apr 15 2018 18:38
wanna try out doing it on python? im really bad at it but we can do it just for the fun
Pieter Stokkink
@forkerino
Apr 15 2018 18:39
sure
my python is miserable too
:P
then its close to a fair fight still the only thing I did in python was nothing more than loops and if elses :D
Pieter Stokkink
@forkerino
Apr 15 2018 18:40
let's see!
Tiago Correia
@tiagocorreiaalmeida
Apr 15 2018 18:52
I compeltly forgot the syntax of this
I can't evne write the loop correctly crap :D
Pieter Stokkink
@forkerino
Apr 15 2018 18:52
it seems like regular javascript
not python
Tiago Correia
@tiagocorreiaalmeida
Apr 15 2018 18:52
you didnt changed the language on top right :D
Pieter Stokkink
@forkerino
Apr 15 2018 18:53
ah, should I do that myself?
fudge
I just saw js
whoops
sorry
Tiago Correia
@tiagocorreiaalmeida
Apr 15 2018 18:53
no worries I did the second one as javascript too, this thing didnt changed all of the exercises you need to do it one by one :\
Pieter Stokkink
@forkerino
Apr 15 2018 18:54
weird that you cannot do a python tournament
for example
Tiago Correia
@tiagocorreiaalmeida
Apr 15 2018 18:55
indeed, lets do a javascript one? need to pratice more python ahah
Pieter Stokkink
@forkerino
Apr 15 2018 18:59
I did port my JS solutions to python solutions within the time, though. :)
Tiago Correia
@tiagocorreiaalmeida
Apr 15 2018 18:59
ups :\ I closed it ahha
https://codefights.com/tournaments/4xJ6PMEaSrLDSXywj come js one makes more sense to do it this way
Pieter Stokkink
@forkerino
Apr 15 2018 19:00
sure
last one, then I
'm off
Pieter Stokkink
@forkerino
Apr 15 2018 19:14
Jeez, I'm crashing
Tiago Correia
@tiagocorreiaalmeida
Apr 15 2018 19:14
same..
:\
I didnt even got the right idea one the first one crappp, anyway congrats and have a good weekend :)
Pieter Stokkink
@forkerino
Apr 15 2018 19:16
@tiagocorreiaalmeida thanks, you too!
CamperBot
@camperbot
Apr 15 2018 19:16
forkerino sends brownie points to @tiagocorreiaalmeida :sparkles: :thumbsup: :sparkles:
:cookie: 515 | @tiagocorreiaalmeida |http://www.freecodecamp.org/tiagocorreiaalmeida
Pieter Stokkink
@forkerino
Apr 15 2018 19:16
the second one was hard
Tiago Correia
@tiagocorreiaalmeida
Apr 15 2018 19:16
you got it done?
Pieter Stokkink
@forkerino
Apr 15 2018 19:16
one test failed
Tiago Correia
@tiagocorreiaalmeida
Apr 15 2018 19:16
the third one was even more complex :D
Pieter Stokkink
@forkerino
Apr 15 2018 19:16
only had a brief look at it in the last 10 seconds
Brittany Rutherford
@brittanyrutherford
Apr 15 2018 21:16
hi all, can anyone help me with an issue on codepen
I am trying to make it that, when i click on open, it opens a modal dialog, the effect on the background is working fine, however the modal scale(1) is not working
jusgoose
@gusd773
Apr 15 2018 21:17
blob
anybody know what this means or how to fix? installing laravel rn
I am using mysql workbench & mamp for windows
Dan Malone
@danmalone89
Apr 15 2018 21:28
Is there a cleaner and more efficient way to do multiple API calls than this? I want to perform 2-3 GETs once the user clicks a button. This is for a very simple app but this requires a lot more lines than needed, right?
  $.ajax({
    url: '',
    type: '',
    success: 
    error: 
  });
  $.ajax({
    url: '',
    type: '',
    success: 
    error: 
  });
Tiago Correia
@tiagocorreiaalmeida
Apr 15 2018 22:49
Hum create a function that makes the ajax request and you pass the info you need to the function, stuff like the url and all of, that, would only change the part of repeating three times the same thing other than that.no idea :smile:
Stephen James
@sjames1958gm
Apr 15 2018 23:26
@danmalone89 You could use the fetch API which uses promises. Which might make the code more readable, but you are still going to have to
call the API multiple times with the right info