These are chat archives for FreeCodeCamp/HelpJavaScript

4th
Jul 2017
Guderian Raborg
@hypercuber
Jul 04 2017 00:01
Can someone help me make the video bigger and horizontally align the boxes about the prices center: https://codepen.io/hypercuber/pen/Ogvqwq
Alexander Køpke
@alexanderkopke
Jul 04 2017 00:12
@hypercuber dunno if this is what you were looking for but:
#howItWorks {
  background-color: rgba(45, 45, 45, 0.1);
  margin-top: 50px;
  /*center with flex*/
  display: flex;
  justify-content: center;
  height: 100vh;
}
 iframe {
    width: 750px;    
  }
Kervtuza
@Kervtuza
Jul 04 2017 00:12
hey guys I am working on the Show Local Weather project and I can't seem to display pictures by url in codepen? https://codepen.io/Kervtuza/pen/RgLzyP
Alexander Køpke
@alexanderkopke
Jul 04 2017 00:16
@Kervtuza the images should probably be https as well
Kervtuza
@Kervtuza
Jul 04 2017 00:17
@alexanderkopke I tried https but i get the same error in the console
Mixed Content: The page at 'https://codepen.io/Kervtuza/pen/RgLzyP' was loaded over HTTPS, but requested an insecure image 'http://foundation.dut.ac.za/sites/default/modules/dut_weather/icons/day-clear.png'. This content should also be served over HTTPS.
oops
tiger500
@tiger500
Jul 04 2017 00:21

// Example
var firstNameLength = 0;
var firstName = "Ada";

firstNameLength = firstName.length;

// Setup
var lastNameLength = 0;
var lastName = "Lovelace";

// Only change code below this line.

lastNameLength = lastName;

i am stuck on this

onejo578
@onejo578
Jul 04 2017 00:27
@tiger500 does it just want you to get the length of the last name? that would be lastName.length;

The Hints page isn't working for this exercise, so can someone help me here?

function repeatStringNumTimes(str, num) {
  // repeat after me
  return str;
}

repeatStringNumTimes("abc", 3);

I have to repeat the string num amount of times. I'm thinking a for loop that tests against num?

Guderian Raborg
@hypercuber
Jul 04 2017 00:29
@alexanderkopke didnt quite work but thanks anyways
CamperBot
@camperbot
Jul 04 2017 00:29
hypercuber sends brownie points to @alexanderkopke :sparkles: :thumbsup: :sparkles:
:star2: 1594 | @alexanderkopke |http://www.freecodecamp.com/alexanderkopke
Gulsvi
@gulsvi
Jul 04 2017 00:30
@Kervtuza You are overwriting your image with your weather Data when you run this: $(".current-weather").html(
Kervtuza
@Kervtuza
Jul 04 2017 00:31
i know
i tried with just one of each
Gulsvi
@gulsvi
Jul 04 2017 00:31
(Also you don't need crossorigin.me - remove that server/proxy and add ?callback=? to the end of your URL)
Kervtuza
@Kervtuza
Jul 04 2017 00:31
it still doesnt work
Gulsvi
@gulsvi
Jul 04 2017 00:31
The image works for me
If you move the <img> out of the current-weather div, it will load fine
Kervtuza
@Kervtuza
Jul 04 2017 00:33
weird....
what caused that?
Gulsvi
@gulsvi
Jul 04 2017 00:33
the .html() method overwrites everything, you were overwriting your <img> tag
Kervtuza
@Kervtuza
Jul 04 2017 00:33
ohhhh! got it!
thank you so much!
@SkyC0der thank you !
CamperBot
@camperbot
Jul 04 2017 00:34
kervtuza sends brownie points to @skyc0der :sparkles: :thumbsup: :sparkles:
:star2: 1929 | @skyc0der |http://www.freecodecamp.com/skyc0der
Gulsvi
@gulsvi
Jul 04 2017 00:34
Happy to help :)
onejo578
@onejo578
Jul 04 2017 00:36

The Hints page isn't working for this exercise, so can someone help me here?

function repeatStringNumTimes(str, num) {
  // repeat after me
  return str;
}

repeatStringNumTimes("abc", 3);

I have to repeat the string num amount of times. I'm thinking a for loop that tests against num? Or the String.prototype.repeat() method?

Saif Ur Rahman
@saifsmailbox98
Jul 04 2017 00:49
@onejo578 why not create a loop that concatenates the string the times it runs.
     str = "abc"
     new=""
 loop start:
     new+=str;
 loop end:
luccifer00
@luccifer00
Jul 04 2017 00:54
Please!, can someone guide me on how can i get this API?? and his KEY?? https://darksky.net/dev/docs/forecast i read the FAQ and i dont need to sign up...
Tristan Michael Lawrence
@tr1s
Jul 04 2017 00:55
How come the “convert to celcius” javascript challenge they expect you to know if/else statements and things like “type of” if it wasn’t taught in the first 10 lessons of JavaScript?
Did I miss something?
luccifer00
@luccifer00
Jul 04 2017 00:57
@tr1s after a month with freecodecamp, i am learning they teach us tha basic of basic, and teach us to keep searching everything you read.... really... i think so...
Coy Sanders
@coymeetsworld
Jul 04 2017 00:58
@tr1s you don't have to worry about that part, it's just for checking your input.
Tristan Michael Lawrence
@tr1s
Jul 04 2017 00:58
interesting
thank you
Coy Sanders
@coymeetsworld
Jul 04 2017 00:58
where did you see that at btw? its not in the code anymore that's old
Tristan Michael Lawrence
@tr1s
Jul 04 2017 00:58
the solution was much easier than i thought i just got confused, and even more confused when i found if/else in the spoiler lol
i clicked ‘help'
Gulsvi
@gulsvi
Jul 04 2017 00:59
@luccifer00 You will need to sign up for an account to get a key
https://darksky.net/dev/register
luccifer00
@luccifer00
Jul 04 2017 01:01
really @SkyC0der I am reading something wrong on his FAQ?
Gulsvi
@gulsvi
Jul 04 2017 01:02
@luccifer00 If you develop an application that uses the dark sky API you cannot ask the users of your application to get their own API key to use your application.
So, in your weather app, you can't add a text field for example and ask people to go register with dark sky and get an API key before they can get their weather
luccifer00
@luccifer00
Jul 04 2017 01:02
ok @SkyC0der my english makes me fail again.... thay talk about end users... thanks
CamperBot
@camperbot
Jul 04 2017 01:02
luccifer00 sends brownie points to @skyc0der :sparkles: :thumbsup: :sparkles:
:star2: 1931 | @skyc0der |http://www.freecodecamp.com/skyc0der
Scarlet L.
@S1L9L8E9
Jul 04 2017 01:15
I'm so lost with the escaping literal quotes
Tristan Michael Lawrence
@tr1s
Jul 04 2017 01:15
I just finished that one, what seems to be the problem?
140?
Scarlet L.
@S1L9L8E9
Jul 04 2017 01:19
I seems like to me that I am doing things right but I'm obviously missing something
var myStr = "I am a \"double quoted\ string inside \"double quotes \".";
Tristan Michael Lawrence
@tr1s
Jul 04 2017 01:20
@S1L9L8E9 just need an ‘a’ after string ‘string inside
missing one letter
wait let me look again lol
@S1L9L8E9 you’re missing double qoutes after 'quoted'
@S1L9L8E9 \”doubled quoted\"
Scarlet L.
@S1L9L8E9
Jul 04 2017 01:22
Okay progress! thank you so much!
at least I got one
haha
Tristan Michael Lawrence
@tr1s
Jul 04 2017 01:22
@S1L9L8E9 no problem hah!
Keon Samuel
@keonsam
Jul 04 2017 01:27
who needs help?
Eric Hasegawa
@EricHasegawa
Jul 04 2017 01:29
@keonsam I do
Keon Samuel
@keonsam
Jul 04 2017 01:29
on?
Eric Hasegawa
@EricHasegawa
Jul 04 2017 01:29

function getIndexToIns(arr, num) {

  var newArr = arr.sort();

for (var i = 0; i < arr.length; i++) {
  if (arr[i] >= num) 
    return i;
}
  return arr.length;


}

getIndexToIns([40,60], 50);
could you tell me why this doesn't work? it's the "where do I belong" challenge
Tristan Michael Lawrence
@tr1s
Jul 04 2017 01:29
@keonsam i wouldn’t mind some clarification. Does using single quotes like ‘this’ mean you don’t have to escape double quotes inside the string?
Keon Samuel
@keonsam
Jul 04 2017 01:30
yes
or the other way around
Tristan Michael Lawrence
@tr1s
Jul 04 2017 01:30
ok thanks @keonsam
CamperBot
@camperbot
Jul 04 2017 01:30
tr1s sends brownie points to @keonsam :sparkles: :thumbsup: :sparkles:
:cookie: 410 | @keonsam |http://www.freecodecamp.com/keonsam
Keon Samuel
@keonsam
Jul 04 2017 01:31
'start of string "quote" end of string.'
Tristan Michael Lawrence
@tr1s
Jul 04 2017 01:31
Ooo you just have to say thanks to give someone brownie points
@S1L9L8E9
@S1L9L8E9 could I get that from you, you’re the first person I’ve helped ha
Scarlet L.
@S1L9L8E9
Jul 04 2017 01:32
@tr1s definitely!
how do I do that XD
Tristan Michael Lawrence
@tr1s
Jul 04 2017 01:33
hahahah
you have to @ me and then say thanks!
Eric Hasegawa
@EricHasegawa
Jul 04 2017 01:34
@keonsam You still here?
Tristan Michael Lawrence
@tr1s
Jul 04 2017 01:34
@S1L9L8E9 ty
CamperBot
@camperbot
Jul 04 2017 01:34
tr1s sends brownie points to @s1l9l8e9 :sparkles: :thumbsup: :sparkles:
:cookie: 92 | @s1l9l8e9 |http://www.freecodecamp.com/s1l9l8e9
Tristan Michael Lawrence
@tr1s
Jul 04 2017 01:34
@S1L9L8E9 like that ha
Scarlet L.
@S1L9L8E9
Jul 04 2017 01:34
@tr1s thanks!
CamperBot
@camperbot
Jul 04 2017 01:34
s1l9l8e9 sends brownie points to @tr1s :sparkles: :thumbsup: :sparkles:
:cookie: 142 | @tr1s |http://www.freecodecamp.com/tr1s
Tristan Michael Lawrence
@tr1s
Jul 04 2017 01:35
Awesome!
Keon Samuel
@keonsam
Jul 04 2017 01:45
@EricHasegawa your sort needs a little work
function getIndexToIns(arr, num) {

  var newArr = arr.sort();
for (var i = 0; i < newArr.length; i++) {
  if (num < = newArr[i]){
    return i;
  }
}
  return arr.length;


}
fix the syntax a little
the sort needs work
example 
numbers.sort(function(a, b) {
  return a - b;
});
Eric Hasegawa
@EricHasegawa
Jul 04 2017 01:50
@keonsam I got it, thank you!
CamperBot
@camperbot
Jul 04 2017 01:50
erichasegawa sends brownie points to @keonsam :sparkles: :thumbsup: :sparkles:
:cookie: 411 | @keonsam |http://www.freecodecamp.com/keonsam
Eric Hasegawa
@EricHasegawa
Jul 04 2017 01:51
Could you explain how the sort parameters work? Like where (a,b) comes from etc.?
Aaron Bell
@awb715
Jul 04 2017 01:51
anyone wanna help me strategize my api calls in my webapp?
Scarlet L.
@S1L9L8E9
Jul 04 2017 01:53
I mean like how prevalent is escaping quotes in actual coding
lol
Joseph
@revisualize
Jul 04 2017 01:54
hi
Aaron Bell
@awb715
Jul 04 2017 01:55
revisualize
the dude
im building a webapp
app.post('/Info', function (req, res) {
    var State = req.body.State;
    var income = Number(req.body.income);
    axios.post('https://taxee.io/api/v2/calculate/2017', {
        //data sent to Taxee.io
        "exemptions": 1
        , "filing_status": "single"
        , "pay_periods": 1
        , "pay_rate": income || 100000
        , "state": State || "NY"
    }, {
        headers: {
            'Authorization': "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJBUElfS0VZX01BTkFHRVIiLCJodHRwOi8vdGF4ZWUuaW8vy9zY29wZXMiOlsiYXBpIl0sImlhdCI6MTQ5OTA1MzU0NX0.pOwC5JEC7trLaaZVgHHGu_rvN0-EGa3RMm8BgJ-M9gk"
                //headers
        }
    }).then(function (response) {
        console.log(response.data.annual, 'this is Taxes');
        var obj = {
            fica: response.data.annual.fica
            , federal: response.data.annual.federal
            , state: response.data.annual.state
        };
        console.log(obj);
        ///issue is here
axios.get(`https://www.quandl.com/api/v3/datasets/ZILL/Z98112_RMP.json?api_key=d7xQahcK4CM1LVd`).then(function (response) {
            return obj.rent = response.data.dataset.data[0][1];
        }).then(function (response) {
            res.send(obj);
        });
    }).catch(function (error) {
        console.log(error);
    });
});
Joseph
@revisualize
Jul 04 2017 02:18
Free book: https://www.packtpub.com/packt/offers/free-learning Today it is: Responsive Web Design with HTML5 and CSS3 - Second Edition
@awb715 cool... I'm on some sweet meds.
Aaron Bell
@awb715
Jul 04 2017 02:21
i have a working server that sends back what i need but im struggling to make some important decisions
wanna hear about them?
Joseph
@revisualize
Jul 04 2017 02:22
Ummm... I just got out of surgery
You could tell me the most amazing shit
I'll forget
Aaron Bell
@awb715
Jul 04 2017 02:26
haha
well its built on express
so when i submit a form the data gets sent to 2 APIs
first api is a tax calculator
2nd api is a median rent
from there I plan to take the given salary and deduct both tax and yearly rent
Aaron Bell
@awb715
Jul 04 2017 02:27
andthen the person will be able to budget
Joseph
@revisualize
Jul 04 2017 02:29
seriously, I'm on some strong pain meds.
they put a metal plate in my wrist
Andy
@akjellis
Jul 04 2017 02:34
Hello
Joseph
@revisualize
Jul 04 2017 02:36
Hello
Andy
@akjellis
Jul 04 2017 02:36
Need some Jquery help
that's the jquery room
Andy
@akjellis
Jul 04 2017 02:36
yeah, I posted in there, no one is answering
thanks
Joseph
@revisualize
Jul 04 2017 02:38
@akjellis you can post in here or main room too
@akjellis Sorry. I'm trying to help as much as I can
Junaid Gehlot
@junaid07
Jul 04 2017 02:40

function rot13(str) { // LBH QVQ VG!
str = str.split('').map(cipher).join("");
return str;
function cipher(letter){
var symbolRegex = /[^a-zA-B]/g;
if(symbolRegex.test(letter)){
return letter;
}
var codeASCII = letter.charCodeAt(0);
if(codeASCII > 78){
codeASCII -= 13;
}else{
codeASCII +=13;
}

return String.fromCharCode(codeASCII);

}

}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
What am i doing wrong??

slertka
@slertka
Jul 04 2017 02:43
Hi -- I need help with the geolocation API
I want to integrate the latitude and longitude into a URL but it returns undefined when called
slertka
@slertka
Jul 04 2017 02:44
I used that thanks @shivam gupta
CamperBot
@camperbot
Jul 04 2017 02:44
slertka sends brownie points to @shivam :sparkles: :thumbsup: :sparkles:
:warning: @shivam's account is not linked with freeCodeCamp. Please visit the settings and link your GitHub account.
shivam gupta
@shivamg11000
Jul 04 2017 02:44
read something about synchronus and asynchronus
@slertka
slertka
@slertka
Jul 04 2017 02:45
Ok will check it out thanks @shivamg11000
CamperBot
@camperbot
Jul 04 2017 02:45
slertka sends brownie points to @shivamg11000 :sparkles: :thumbsup: :sparkles:
:cookie: 353 | @shivamg11000 |http://www.freecodecamp.com/shivamg11000
shivam gupta
@shivamg11000
Jul 04 2017 02:45
@slertka then pm me
slertka
@slertka
Jul 04 2017 02:45
will do
shivam gupta
@shivamg11000
Jul 04 2017 02:45
I will tell you something
SaiChand Duppala
@saichandd
Jul 04 2017 02:47
@slertka I guess you are calling them outside the AJAX, because its asynchronous, it'll give undefined
shivam gupta
@shivamg11000
Jul 04 2017 02:47
@imRadioactive thats why I am telling her to read first about sync and async
slertka
@slertka
Jul 04 2017 02:47
yes i think that's my problem. trying to read and fix.
SaiChand Duppala
@saichandd
Jul 04 2017 02:48
@shivamg11000 ohyeah didnt see that
shivam gupta
@shivamg11000
Jul 04 2017 02:48
giving direct solution will do no benefit
SaiChand Duppala
@saichandd
Jul 04 2017 02:50
yeah true, I just told something which she cannot be undestood without searching :smile:
Raymond Igle
@r-igle
Jul 04 2017 03:18
@junaid07 I took the easy route and initialize an alphabet array and worked out the math - I put some print statements in your code and see that your reg test is returning false every time and only one letter changes successfully. You can get closer to the result by narrowing the reg ex to /[^A-Z]/ which is all that's needed according to specs.
<script>
function rot13(str) { // LBH QVQ VG!
    str = str.split('').map(cipher).join("");
    document.write(str + "<br/>");
    return str;

    function cipher(letter){
        var symbolRegex = /[^A-Z]/;
        if(symbolRegex.test(letter)){
            document.write(symbolRegex.test(letter) + "<br/>"); 
            return letter;
        }

        var codeASCII = letter.charCodeAt(0);
        document.write(codeASCII + " " + letter + "<br/>");
        if(codeASCII > 78){
            codeASCII -= 13;
        }else{
            codeASCII +=13;
        }
        return String.fromCharCode(codeASCII);
    }
}
document.write(rot13("SERR PBQR PNZC"));
</script>
Tai Jones
@taiJones00
Jul 04 2017 03:22
function mystery(input) {
var secret = 4;
input += 2;
function mystery2(multiplier) {
multiplier = input;
return secret
multiplier;
}
return mystery2;
}
var hidden = mystery(3);
is three put in as an argument for mystery 1 and 2
like 3 will equal input and multiplier
Raymond Igle
@r-igle
Jul 04 2017 03:29
should it be secret*multiplier? @taiJones00
shivam gupta
@shivamg11000
Jul 04 2017 03:37
class conversion for this
function Ball(r){
  this.r = r;

  this.draw = function(){
    draw something
  }
  this.update = function(){
    update something
 }
}
anyine
codewarg
@codewarg
Jul 04 2017 03:38

1)
function average(score){
var sum = 0;
for(var i = 0; i < score.length; i++){

sum+=score[i]}

var avg = (sum/score.length);
Math.round(avg);
return console.log(avg);

}

var odds =[90,98,89,100,100,86,94];
average(odds);

2)
function average(score){
var sum = 0;
for(var i = 0; i < score.length; i++){

sum+=score[i]}

var avg = (sum/score.length);
return Math.round(avg);

}

var odds =[90,98,89,100,100,86,94];
console.log(average(odds));
help please im trying to understand
why does the Math.round() not excuted in 1

Manish Giri
@Manish-Giri
Jul 04 2017 03:41
it does
but you're not saving it anywhere
codewarg
@codewarg
Jul 04 2017 03:45
i thought the avg variable was saved already because it does return 94 when i use console.log while calling the function but its does not when i include console.log within the function
Manish Giri
@Manish-Giri
Jul 04 2017 03:47
I'm not sure what these lines are meant to do
Math.round(avg);
return console.log(avg);
1 - you're not saving the value of Math.round
2 - you're returning a console.log, which is..weird?
codewarg
@codewarg
Jul 04 2017 03:49
okay i actually see what you meant and it make sense now, thank you much
Ogundele Olumide
@Lumexralph
Jul 04 2017 04:03
@Manish-Giri :smirk: insomniac
Manish Giri
@Manish-Giri
Jul 04 2017 04:03
:smiling_imp:
ggm :bow:
Ogundele Olumide
@Lumexralph
Jul 04 2017 04:03
good morning
@Manish-Giri Should finally start pomodoro
Manish Giri
@Manish-Giri
Jul 04 2017 04:04
all ze best
Ogundele Olumide
@Lumexralph
Jul 04 2017 04:04
:joy: not so fast though
Jor
@joreyesl
Jul 04 2017 04:09
sggm :smiling_imp: @Manish-Giri
Manish Giri
@Manish-Giri
Jul 04 2017 04:10
:scream:
sssgggggmmmm
:bow: @joreyesl
Jor
@joreyesl
Jul 04 2017 04:10
lol
Ogundele Olumide
@Lumexralph
Jul 04 2017 04:12
:gggggggggggggm :smiling_imp: all awake
Jor
@joreyesl
Jul 04 2017 04:13
the council of :smiling_imp:
Manish Giri
@Manish-Giri
Jul 04 2017 04:14
more like :smiling_imp: 's Creed
Jor
@joreyesl
Jul 04 2017 04:14
:laughing:
Ogundele Olumide
@Lumexralph
Jul 04 2017 04:27

more like :smiling_imp: 's Creed

:+1:

BlackTiger
@BlackTigerRoar
Jul 04 2017 04:52
Did FCC updated recently? In the problem, instead of showing "Get Help" and linked to chat room. Now it's showing "Get a hint", and linked to the forum?
M-C-Haker
@M-C-Haker
Jul 04 2017 04:52

where am i wrong?
function largestOfFour(arr) {
var largeArr = [];
for (var i = 0; i < arr.length; i++) {
var largest = arr[i][0];
for (var j = 1; j < arr[i].length; j++) {
if (arr[i][j] > largest) {
largeArr = arr[i][j];
}
}
largest[i] = largeArr;
}
return largeArr;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);

BlackTiger
@BlackTigerRoar
Jul 04 2017 04:55

@M-C-Haker

if (arr[i][j] > largest) {
largeArr = arr[i][j];
}
}
largest[i] = largeArr;
}
return largeArr;
}

Unless there's a short cut, otherwise, you are missing else if, and else

SaiChand Duppala
@saichandd
Jul 04 2017 04:56
@M-C-Haker it should be var largeArr[i] = arr[i][j]
sorry, no var
M-C-Haker
@M-C-Haker
Jul 04 2017 04:58
@imRadioactive i'm gettingg cannot create property '0' on number '4'
SaiChand Duppala
@saichandd
Jul 04 2017 05:01
@M-C-Haker sorry, I didnt get you, you are assigning values largeArr instead of its elemnts, just assign them to elemnts and it should work fine I guess
Moisés Man
@moigithub
Jul 04 2017 05:06
@M-C-Haker u mixing up ur variables names....
Neel
@NeelDVirus
Jul 04 2017 05:07
in the code below i expected the result of destroyer([1, 2, 3, 1, 2, 3], 2, 3); would be [1,1].
But the result pops out to be [1,2,3,1,2,3]. Where i am doing wrong
function destroyer(arr) {
  // Remove all the values
  function hlp(x) {
    for(var i=1; i<arguments.length ; i++) {
      if(x === arguments[i]) return false;
    }
    return true;
  }
  return arr.filter(hlp);
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
BlackTiger
@BlackTigerRoar
Jul 04 2017 05:10
@M-C-Haker I would sort your array from largest to smallest first, so you know that arr[i][0] is always the largest number.
wonder
@wonder2991
Jul 04 2017 05:13
function largestOfFour(arr) {
var largeArr = [];
for (var i = 0; i < arr.length; i++) {
var largest = arr[i][0];
for (var j = 0; j < arr[i].length; j++) {
if (arr[i][j] > largest) {
largest = arr[i][j];
}
}
largeArr[i] = largest ;
}
return largeArr;
}
console.log(largestOfFour([[4, 5, 1, 3], [13, 29, 12, 2], [32, 35, 37, 39], [1000, 1001, 857, 1]]));
this seem to work
Ronald T. Casili
@nvlled
Jul 04 2017 05:43
@NeelDVirus Try console.log on arguments and you'll see the problem
ktkim980
@ktkim980
Jul 04 2017 05:59

Instructions
Assign the following three lines of text into the single variable myStr using escape sequences.

FirstLine
\SecondLine\
ThirdLine

how to do this???
been stuck for hours
h1tag
@h1tag
Jul 04 2017 06:01
@ktkim980 what have you tried?
BlackTiger
@BlackTigerRoar
Jul 04 2017 06:08
@ktkim980 you can do it!
Bomee
@Bomulacious
Jul 04 2017 06:13
can someone help me what's missing/wrong? function truncateString(str, num) {
// Clear out that junk in your trunk
if (num>3){
return str.slice(0,num-3) +"...";
} else if (str.length<= num){
return str.slice(0);
} else if (num<=3){
return str.slice(0,num)+"...";
}
}
link - https://www.freecodecamp.com/challenges/truncate-a-string
Viktor Tiutiun
@vittorioVT
Jul 04 2017 06:19
@Bomulacious you need three conditions: if (num > 3 && num < 15)
else if (num < 3)
else if (num > 15)
Bomee
@Bomulacious
Jul 04 2017 06:22
i have 3 conditions, why are my conditions no adequate? @vittorioVT
Pieter Stokkink
@forkerino
Jul 04 2017 06:26
@Bomulacious your second if can be true even if the first one is true. The order of them matters
h1tag
@h1tag
Jul 04 2017 06:26
@Bomulacious in the 1st condition, you're only checking if num > 3
Bomee
@Bomulacious
Jul 04 2017 06:27
@forkerino ohhhhhh I see! thank you!!
CamperBot
@camperbot
Jul 04 2017 06:27
bomulacious sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2813 | @forkerino |http://www.freecodecamp.com/forkerino
Pieter Stokkink
@forkerino
Jul 04 2017 06:27
:+1:
Bomee
@Bomulacious
Jul 04 2017 06:27
thanks guys! @vittorioVT @h1tag
CamperBot
@camperbot
Jul 04 2017 06:27
bomulacious sends brownie points to @vittoriovt and @h1tag :sparkles: :thumbsup: :sparkles:
:cookie: 761 | @vittoriovt |http://www.freecodecamp.com/vittoriovt
:cookie: 888 | @h1tag |http://www.freecodecamp.com/h1tag
h1tag
@h1tag
Jul 04 2017 06:27
but you don't know if the string length is greater than the num
Bomee
@Bomulacious
Jul 04 2017 06:27
@h1tag riiiggggghhhhtt haha
Tai Jones
@taiJones00
Jul 04 2017 06:43
can someone experienced in closure help me
Pieter Stokkink
@forkerino
Jul 04 2017 06:58
@taiJones00 what's your question?
Joseph
@revisualize
Jul 04 2017 07:10
hi
@Bomulacious note: you do NOT need 3 if conditions for that challenge
@Bomulacious In fact, you shouldn't be hard coding those if conditions
Mai Thinh
@mthinh
Jul 04 2017 07:16
image.png
im doing quote machine, then i receive this ?
it works. but something it appear "undefined"?
does anyone know why? pls ?
Stuhl
@Stuhl
Jul 04 2017 07:25
Have u got reference for ur html elements ? Eg var quoteAuthor = document.getElementById(“qu
(
(“quote-gontainer“)
Cuz otherwise it wont find the element put the quote on
Mai Thinh
@mthinh
Jul 04 2017 07:26
yah i do
it works. but sometimes, undefined appear randomly
image.png
Stuhl
@Stuhl
Jul 04 2017 07:27
Hmm then I dunno, sry
Mai Thinh
@mthinh
Jul 04 2017 07:27
its ok
Stuhl
@Stuhl
Jul 04 2017 07:27
Im not that far tbh in the challenges lol
alpox
@alpox
Jul 04 2017 07:30
@mthinh I could take a look if you share your pen
Ronald T. Casili
@nvlled
Jul 04 2017 07:30
@mthinh If it's random, then it's probably the quote fetched from random quote API. Did you try doing console.log on the response?
@nvlled yah , youre right, maybe there sth wrong in repsonse text
alpox
@alpox
Jul 04 2017 07:33
@mthinh When using plain XMLHttpRequest you should check the status for if its 200
I was not able to get undefined though :D
Mai Thinh
@mthinh
Jul 04 2017 07:34
haha thank you :3 it works @alpox
CamperBot
@camperbot
Jul 04 2017 07:34
mthinh sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:star2: 1209 | @alpox |http://www.freecodecamp.com/alpox
Mai Thinh
@mthinh
Jul 04 2017 07:36
does it need to be responsive for this project ?
alpox
@alpox
Jul 04 2017 07:36
It should always be responsive :D
Mai Thinh
@mthinh
Jul 04 2017 07:36
okie :D
makalohri
@makalohri
Jul 04 2017 07:40
@knrt10 Thank you mate
CamperBot
@camperbot
Jul 04 2017 07:40
makalohri sends brownie points to @knrt10 :sparkles: :thumbsup: :sparkles:
:cookie: 447 | @knrt10 |http://www.freecodecamp.com/knrt10
Long Nguyen
@longnt80
Jul 04 2017 08:01
What is the get in get area()?
class Rectangle {
  constructor(height, width) {
    this.height = height;
    this.width = width;
  }

  get area() {
    return this.calcArea();
  }

  calcArea() {
    return this.height * this.width;
  }
}

const square = new Rectangle(10, 10);

console.log(square.area);
Long Nguyen
@longnt80
Jul 04 2017 08:13
@sjurs1 thanks man
CamperBot
@camperbot
Jul 04 2017 08:13
longnt80 sends brownie points to @sjurs1 :sparkles: :thumbsup: :sparkles:
:cookie: 306 | @sjurs1 |http://www.freecodecamp.com/sjurs1
Will Waymel
@willwaymel
Jul 04 2017 08:18
i'm going crazy trying to play a sound by accessing it's index in an object I made... trying to do it dynamically in the Simon game based on which button is pressed and passing the data value of the button (1, 2, 3, or 4) to the object.... I can play the sound by calling sounds.a(). but it doesn't like keys[0]. any ideas?
var sounds = {
  a: function() {
    audio1.play();
},
b: function() {
  audio2.play();
},
c: function() {
  audio3.play();
},
d: function() {
  audio4.play();
}
};
Or is there a much better way? I'm sure it's not this :)
Manish Giri
@Manish-Giri
Jul 04 2017 08:22
Can you show the code you're using with keys?
Will Waymel
@willwaymel
Jul 04 2017 08:30

I did it! Sorry... didn't see your comment because iwasn't mentioned so I was just trying new things. This was my solution:

var sounds = {
  a: function() {
    audio1.play();
},
b: function() {
  audio2.play();
},
c: function() {
  audio3.play();
},
d: function() {
  audio4.play();
},
key: function(n) {
        return this[Object.keys(this)[n]];
}
};

and this to play sounds.key(1)();

not my solution, i should say but a variation of a solution on stackoverflow :)
june808
@june808
Jul 04 2017 08:33
var myStr ="";
myStr ="This is the first sentence.";
myStr += "This is the second sentence.";
Saif Ur Rahman
@saifsmailbox98
Jul 04 2017 08:43
@june808 add (space) after the first sentence. "This is the first sentence. "
Bashir Harrell
@bookofbash
Jul 04 2017 08:44
Can anyone tell me why this isn't working?
$.getJSON("https://cors-anywhere.herokuapp.com/https://wind-bow.gomix.me/twitch-api", function(json){
    console.log (json);
})
@bookofbash try https://wind-bow.glitch.me/twitch-api/channels/ESL_SC2 ( :point_left: channel name)
Bashir Harrell
@bookofbash
Jul 04 2017 08:48
@saifsmailbox98 , I hate it when the answer is obvious. Thank you
CamperBot
@camperbot
Jul 04 2017 08:48
bookofbash sends brownie points to @saifsmailbox98 :sparkles: :thumbsup: :sparkles:
:cookie: 703 | @saifsmailbox98 |http://www.freecodecamp.com/saifsmailbox98
Saif Ur Rahman
@saifsmailbox98
Jul 04 2017 08:48
$.getJSON("https://wind-bow.gomix.me/twitch-api/channels/ESL_SC2", function(json){
    console.log (json);
})
:+1:
Dan Couper
@DanCouper
Jul 04 2017 08:52

@willwaymel why do you have the extra level of indirection or a, b, c, d, why are you not just using the data value directly (1,2,3,4)? Cos why not just do

function play(dataVal) {
  return ([`audio${dataVal}`].play());
}

// same as

function play(dataVal) {
  return (['audio' +  dataVal].play());
}

or

function play(dataVal) {
  return {
    1: (audio1.play()),
    2: (audio2.play()),
    3: (audio3.play()),
    4: (audio4.play()),
  }[dataval]
}

or

function play(dataVal) {
  return new Map([
    [1, (audio1.play())],
    [2, (audio2.play())],
    [3, (audio3.play())],
    [4, (audio4.play())],
  ]).get(+dataVal)
}

or

function play(dataVal) {
  switch (+dataVal) {
    case 1: (audio1.play()); break;
    case 2: (audio2.play()); break;
    case 3: (audio3.play()); break;
    case 4: (audio4.play()); break;
  }
}

or

function play(dataVal) {
  return [
    (audio1.play()),
    (audio2.play()),
    (audio3.play()),
    (audio4.play()),
  ][+dataval + 1]
}
severusKen
@severusKen
Jul 04 2017 08:56
Capture.PNG
Hi guys, I'm trying to make a validation of my Postal Code format (which is "a0a0a0"), but something is happening with my script, it keeps saying that the format is wrong. Here is my code, please help.
Will Waymel
@willwaymel
Jul 04 2017 08:58
@DanCouper lol because I have no idea what I'm doing. I thought I was adding a layer there but couldn't figure out how to invoke the functions. Thank you for all the solutions
CamperBot
@camperbot
Jul 04 2017 08:58
willwaymel sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
:cookie: 825 | @dancouper |http://www.freecodecamp.com/dancouper
Dan Couper
@DanCouper
Jul 04 2017 08:58
:) hope they're some help
Chris Juchtmans
@kjuchtmans
Jul 04 2017 08:59
morning to each and everyone of you smart folks :wave:
Dan Couper
@DanCouper
Jul 04 2017 09:00
Also, they're in brackets like (audio2.play()) to force execution of the function immediately. If you removed the outer brackets inside the function, (so like 1: audio1.play()), you would call like play(1)() instead
Long Nguyen
@longnt80
Jul 04 2017 09:01
@DanCouper what's the diference between class and construct an object with function?
Chris Juchtmans
@kjuchtmans
Jul 04 2017 09:02

"Wherefore art thou" -- purely subjective question :

Isn't working with (arrays of) objects intrinsically harder than simple lists / arrays?
I'm trying to grow the extra brain twists needed --but they grow sooo slowly :tea:

Dan Couper
@DanCouper
Jul 04 2017 09:03
@longnt80 none really, you get some other niceties (like you can extend, and you get super()), but otherwise you're doing the same thing (those are just sugar)
Long Nguyen
@longnt80
Jul 04 2017 09:03
@DanCouper ok, thanks man
CamperBot
@camperbot
Jul 04 2017 09:03
longnt80 sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
:cookie: 826 | @dancouper |http://www.freecodecamp.com/dancouper
Dan Couper
@DanCouper
Jul 04 2017 09:04
I'm assuming you mean function MyClass() { this.foo = 1; this.bar = 2; } vs class MyClass { constructor() { this.foo = 1; this.bar = 2; }}
a27-suryansh
@a27-suryansh
Jul 04 2017 09:05
Hi i need help with JS can someone please help?
Offline list says undefined means for loop is not executing in my offline list
Will Waymel
@willwaymel
Jul 04 2017 09:07
@DanCouper I tried the first one, but get "[("audio" + buttonDataVal)].play is not a function"
Dan Couper
@DanCouper
Jul 04 2017 09:07
@longnt80 it's literally exactly the same (with those niceties I mentioned, + some downsides (no private properties at the minute, no decorators at the minute)) - class exists because a. syntax is simpler, b. it's easier to understand coming from C#/Java etc, c. there were 10,000,000 different implementations of class patterns, so it makes it easier if there is only one
Long Nguyen
@longnt80
Jul 04 2017 09:07
@DanCouper yes, that's what I meant
heroiczero
@heroiczero
Jul 04 2017 09:07
@a27-suryansh try data.display_name for your "https://wind-bow.gomix.me/twitch-api/channels/"+channels[i] + "?callback=?" this one
a27-suryansh
@a27-suryansh
Jul 04 2017 09:08
ok let me try @heroiczero
I did that @heroiczero but result is same
Dan Couper
@DanCouper
Jul 04 2017 09:12

@willwaymel ah crap, sorry, ignore those ones - I was looking at it like an object with different sounds

const mySounds = {
  audio1: play() { /* dostuff */ }
  audio2: play() { /* dostuff */ }
}

In that case, mySounds['audio' + myNum] would work, I put that right in the end & didn't think about it :\

Will Waymel
@willwaymel
Jul 04 2017 09:14
@DanCouper ah ok... no worries, thanks
CamperBot
@camperbot
Jul 04 2017 09:14
willwaymel sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
:warning: willwaymel already gave dancouper points
Long Nguyen
@longnt80
Jul 04 2017 09:16
@willwaymel hey man, I'm working on the Simin Game too
Will Waymel
@willwaymel
Jul 04 2017 09:16
@longnt80 how's it going?
Long Nguyen
@longnt80
Jul 04 2017 09:16
@willwaymel I'm currently exploring the Web Audio API, it's interesting
Will Waymel
@willwaymel
Jul 04 2017 09:17
@longnt80 yeah I was looking at that yesterday for the first time... was a bit overwhelmed
Long Nguyen
@longnt80
Jul 04 2017 09:18
@willwaymel I know man
@willwaymel it's starting to make sense for me now
Will Waymel
@willwaymel
Jul 04 2017 09:19
@longnt80 that's good... I thought, well I'll try implementing this simple playback now and go back to it after I finish the simon project... I didn't want to fall down a rabbit hole when there was a simpler way... though I don't like the audio files provided by the fcc challenge
Long Nguyen
@longnt80
Jul 04 2017 09:20
@willwaymel here's an article in case you want to leanr the API: https://css-tricks.com/introduction-web-audio-api/
Will Waymel
@willwaymel
Jul 04 2017 09:20
@longnt80 thanks. I've started to find I really like the css-tricks website, it's turning into a common resource.
CamperBot
@camperbot
Jul 04 2017 09:20
willwaymel sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
:cookie: 425 | @longnt80 |http://www.freecodecamp.com/longnt80
Long Nguyen
@longnt80
Jul 04 2017 09:20
this article break down the steps so you can understand it easier
Dan Couper
@DanCouper
Jul 04 2017 09:20
@willwaymel switch is possibly cleaner in thi
Will Waymel
@willwaymel
Jul 04 2017 09:21
@DanCouper I went back to my first solution, but the audio sometimes doesn't play if i click too quickly together, any idea why that would be?
Dan Couper
@DanCouper
Jul 04 2017 09:21
Ha, sorry, just opened the app on my phone and it had the start of a reply, that wasn't meant to be posted 🙃
2 secs
Will Waymel
@willwaymel
Jul 04 2017 09:22
no worries @DanCouper
@longnt80 yeah that is a lot cleaner than the firehose the api website looks like
Dan Couper
@DanCouper
Jul 04 2017 09:23
events firing too quickly I guess, I assume it needs some time to load and fire
@longnt80 oh, I just saw your original question on get, getters and setters have been in JS for a long time but imo they're useless, because JS doesn't work the same way as other OO languages (I've never ever seen a good use for them)
Will Waymel
@willwaymel
Jul 04 2017 09:28
@DanCouper @longnt80 here's my progress. ... now I just have to cancel the timeouts when you turn off the game .... i think it works more or less like it should. https://codepen.io/willwaymel/pen/bRMNap?editors=0010
@DanCouper @longnt80 I've got to go take a break and pick up the kids. thanks for the help. It really helps me learn this much better to hear people who know this stuff much better than me
CamperBot
@camperbot
Jul 04 2017 09:28
willwaymel sends brownie points to @dancouper and @longnt80 :sparkles: :thumbsup: :sparkles:
:warning: willwaymel already gave longnt80 points
:warning: willwaymel already gave dancouper points
Long Nguyen
@longnt80
Jul 04 2017 09:30
@willwaymel np man
Dan Couper
@DanCouper
Jul 04 2017 09:34
@willwaymel that sees pretty good so far - everything seems to be good (bar those timeout cancellations, but with those, you just need to make sure you have the timeout referenced with a variable name, then when you hit stop you should be able to just do clearTimeout(myTimout))
Neel
@NeelDVirus
Jul 04 2017 09:46
@nvlled console.log is showing no error, just the output result is being unexpected
Tobias
@topalaj
Jul 04 2017 09:53
Hi Guys, I'm doing the Random Quote Machine Project and my quote only updates once:
$(document).ready(function() {
$(".btn").on("click", function(){
$("#box").html(quote[0]+"<br><i>"+quote[1]+"</i>");
});
});
var quote= randomQuote()
function randomQuote(){
var quotes=[["This is a test quote.","~Timo Test"],["Another Quote","~Arno Another"]];
var num = Math.floor(Math.random()*quotes.length);
return quotes[num];
}
Chris Juchtmans
@kjuchtmans
Jul 04 2017 09:54

"Wherefore art thou"

In this code: arr = collection.filter(function (obj){
how does compiler know to work with objects in array for callback function, if obj has not been initiated before?

is obj some pre-defined concept in JS, de facto referring to objects?

cheers!

heroiczero
@heroiczero
Jul 04 2017 09:54
@topalaj when you press the button you should get a new random number
Jianhao Tan
@jaanhio
Jul 04 2017 09:55

Hi all, i am trying to restrict toggling of the start button only when game is switched on.

$("#on-off").click(function(){
    $("#switch").toggleClass("switch-on");
  });
if($("#switch").hasClass("switch-on")){
    $("#start-stop").click(function(){
      $("#start-stop").toggleClass("start-game");
    });
  }

is there anything wrong with above syntax? doesnt seem to work

it is for the Simon Game challenge
Thayyeb salim
@Thayyebsalim
Jul 04 2017 09:56
I hate Two dimensional arrays
anyone know worthwhile reads
Tobias
@topalaj
Jul 04 2017 09:57
@heroiczero Yep, the num var updates every time, however the Text with id=box only changes once. I not sure where I went wrong.
heroiczero
@heroiczero
Jul 04 2017 09:57
@kjuchtmans obj is a variable of a function
@kjuchtmans or a parameter
Chris Juchtmans
@kjuchtmans
Jul 04 2017 09:59
@heroiczero so, by running the function against collection -which is an array of objects- obj will in practice refer to objects in it?
that is, I'm free to call it icecream instead of obj?
heroiczero
@heroiczero
Jul 04 2017 10:01
@kjuchtmans yes you can call it whatever you want because it is a parameter of a function you are creating
Chris Juchtmans
@kjuchtmans
Jul 04 2017 10:01
@heroiczero that's it. great, thanks!
CamperBot
@camperbot
Jul 04 2017 10:01
kjuchtmans sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
:star2: 1454 | @heroiczero |http://www.freecodecamp.com/heroiczero
Neel
@NeelDVirus
Jul 04 2017 10:22
arguments.caller is specified as obsolete in MDN. is there any alternative for arguments.caller?
Ogundele Olumide
@Lumexralph
Jul 04 2017 10:24
@NeelDVirus what are you trying to do?
Neel
@NeelDVirus
Jul 04 2017 10:25
@Lumexralph i am passing you the code. just a sec
Mohamed Wahshey
@mohamedwahshey
Jul 04 2017 10:27
Hello, can someone guide me with what do i have to study to be able to create a private api for snapchat, thanks.
Kriis1
@Kriis1
Jul 04 2017 10:31
var expression = /and./gi;
var andCount = testString.match(expression).length; Hello what is wrong with my code? who can help me?
Sift through Text with Regular Expressions
Neel
@NeelDVirus
Jul 04 2017 10:32
This message was deleted
Neel
@NeelDVirus
Jul 04 2017 10:33

@Lumexralph the first code is where i started, the expected output should be [1,1] but it showed [1,2,3,1,2,3]
Then i figured out that i need to pass the arguments object of destroyer function as an argument to the help function.
And then i wrote the secound code which still need some errors to fix (i just now edited so i haven't yet even checked what are the error)
So whats your opinion for the secound code?
(I made some edit again and it seems arguments.caller is not required)

First Code

function destroyer(arr) {
  function hlp(x) {
    for(var i=1; i<arguments.length ; i++) {
      if(x == arguments[i]) return false;
    }
    return true;
  }
  return arr.filter(hlp);
}
console.log(destroyer([1, 2, 3, 1, 2, 3], 2, 3));

Second Code

function destroyer(arr) {
  function hlp() {
    for(var i=1; i<destroyer.arguments.length ; i++) {
      if(x == destroyer.arguments[i]) return false;
    }
    return true;
  }
  return arr.filter(hlp);
}
console.log(destroyer([1, 2, 3, 1, 2, 3], 2, 3));
koder3
@koder3
Jul 04 2017 10:34
@NeelDVirus i think you are missing a {} after your if statements. or is it not needed ?
Neel
@NeelDVirus
Jul 04 2017 10:35
@koder3 {} is not mendatory if the if statement contains only one line statement
Saif Ur Rahman
@saifsmailbox98
Jul 04 2017 10:39
@NeelDVirus what is x?
koder3
@koder3
Jul 04 2017 10:39
@NeelDVirus theres also a spelling error in your 4th line second code. arguments is spelled wrong
Neel
@NeelDVirus
Jul 04 2017 10:40
@koder3 yeah i just now edited the code and fixed some typos and changed some piece of code
wonder
@wonder2991
Jul 04 2017 10:41
where is x defined?
Neel
@NeelDVirus
Jul 04 2017 10:42
@saifsmailbox98 x is any random argument needed to pass in the callback function (here it is hlp) inside a higher-order-function(here it is filter).
@wonder2991 @koder3 OOps i forgot to pass x as the argument in help. editing in now
IggySmith
@IggySmith
Jul 04 2017 10:42
someone explain this task please
image.png
Saif Ur Rahman
@saifsmailbox98
Jul 04 2017 10:42
@NeelDVirus to need to pass that to hlp then, how would the function know? it should be the first parameter.
@IggySmith concatenate the strings, with + operator.
koder3
@koder3
Jul 04 2017 10:43
@NeelDVirus what i did was made a check if any value in arguments[0] was === arguments[1] and in arguments[2] or in arguments[3] (if it exists) if yes filter it out
Neel
@NeelDVirus
Jul 04 2017 10:45
@saifsmailbox98 yeah i cant edit my code anymore... wait goin to repost it with some typos fixed, like passing x in hlp
koder3
@koder3
Jul 04 2017 10:45
or if its not there in arguments[1] or arguments[2] just push it into an empty array
Neel
@NeelDVirus
Jul 04 2017 10:46
@koder3 i am not getting it. are you mentioning about your way of solving or something wrong in my code?
koder3
@koder3
Jul 04 2017 10:46
im mentioning my way
Neel
@NeelDVirus
Jul 04 2017 10:46
This message was deleted
@koder3 oh i appreciate that. there are several alternative ways to solve a specific puzzle. but i am concerned with why my piece of code is not working logically
Saif Ur Rahman
@saifsmailbox98
Jul 04 2017 10:48
@NeelDVirus try this https://repl.it/JMuh, with and without 'use strict';
Neel
@NeelDVirus
Jul 04 2017 10:49
@saifsmailbox98 @koder3 hurreyyy my piece of code is solved :D :D :D
function destroyer(arr) {
  function hlp(x) {
    for(var i=1; i<destroyer.arguments.length ; i++) {
      if(x == destroyer.arguments[i]) return false;
    }
    return true;
  }
  return arr.filter(hlp);
}
console.log(destroyer([1, 2, 3, 1, 2, 3], 2, 3));
IggySmith
@IggySmith
Jul 04 2017 10:49
image.png
@saifsmailbox98 now should i be replacing the dog, big, ran, quickly with the cat stuff??
or create a seperate string
Saif Ur Rahman
@saifsmailbox98
Jul 04 2017 10:49
@IggySmith no, use the parameters like myNoun, myVerb.
wonder
@wonder2991
Jul 04 2017 10:50
@IggySmith let's see your code
Finn Pegler
@FinnPegler
Jul 04 2017 10:50

Why is this an infinite loop? The function is trying to remove all elements from the initial array that are of the same value as the following arguments (2,3,5).

function destroyer(arr) {
arr1 = arguments[0];
argLength = arguments.length;
arr2 = [];

for (var i in arr1) {
for (var j = 1; j < argLength; i++) {
if (arr1[i] !== arguments[j]) {
console.log(arguments[i])
arr2.push(arr1[i]);
}
}
}
console.log(arr2);
}

destroyer([3, 5, 1, 2, 2], 2, 3, 5)

Neel
@NeelDVirus
Jul 04 2017 10:50
@saifsmailbox98 whoaa what's that app?? what the specific use of that app
for console?
Saif Ur Rahman
@saifsmailbox98
Jul 04 2017 10:50
@NeelDVirus app?
Thayyeb salim
@Thayyebsalim
Jul 04 2017 10:51
thank you @saifsmailbox98
Neel
@NeelDVirus
Jul 04 2017 10:51
@saifsmailbox98 not getting the specific term so..
CamperBot
@camperbot
Jul 04 2017 10:51
thayyebsalim sends brownie points to @saifsmailbox98 :sparkles: :thumbsup: :sparkles:
:cookie: 704 | @saifsmailbox98 |http://www.freecodecamp.com/saifsmailbox98
Saif Ur Rahman
@saifsmailbox98
Jul 04 2017 10:51
@NeelDVirus repl.it?
Neel
@NeelDVirus
Jul 04 2017 10:51
@saifsmailbox98 yes
IggySmith
@IggySmith
Jul 04 2017 10:52

@wonder2991 @saifsmailbox98
`
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
myNoun = "dog"; //"cat";
myAdjective ="big"; //"little";
myVerb = "ran"; //"hit";
myAdverb = "quickly"; //"slowly";

result = "My" + " " + myNoun + " " +"is"+" "+ myAdjective +" "+"it"+" "+ myVerb +" "+"very"+" "+ myAdverb;

// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
`

Saif Ur Rahman
@saifsmailbox98
Jul 04 2017 10:52
@IggySmith remove this part
myNoun = "dog"; //"cat";
myAdjective ="big"; //"little";
myVerb = "ran"; //"hit";
myAdverb = "quickly"; //"slowly";
when the call is made it will automatically assign the values to the parameters.
IggySmith
@IggySmith
Jul 04 2017 10:53
remove the part i commented out?
or that entire section
Saif Ur Rahman
@saifsmailbox98
Jul 04 2017 10:53
@IggySmith that entire four lines
IggySmith
@IggySmith
Jul 04 2017 10:54
@saifsmailbox98 @wonder2991 thanks
CamperBot
@camperbot
Jul 04 2017 10:54
iggysmith sends brownie points to @saifsmailbox98 and @wonder2991 :sparkles: :thumbsup: :sparkles:
:cookie: 382 | @wonder2991 |http://www.freecodecamp.com/wonder2991
:cookie: 705 | @saifsmailbox98 |http://www.freecodecamp.com/saifsmailbox98
IggySmith
@IggySmith
Jul 04 2017 10:54
@saifsmailbox98 got it now.. that task is not well explained
Saif Ur Rahman
@saifsmailbox98
Jul 04 2017 10:55
@IggySmith :+1:
Nana Owusu
@nanaowusunyamekye
Jul 04 2017 11:00
hello, can anyone assist with this code, can't seem t get it to pass the test suite written for it
function newUser(name, email, password) {
  //create a new object with properties matching the arguments passed in.
  //return the new object

  this.name = name;
  this.email = email;
  this.password = password;
}

var myUser = new newUser('Nana', 'nanaowusun@gmail.com', 'mypass');
  return myUser;
Saif Ur Rahman
@saifsmailbox98
Jul 04 2017 11:01
why is this part inside of the constructor var myUser = new newUser('Nana', 'nanaowusun@gmail.com', 'mypass');?
Nana Owusu
@nanaowusunyamekye
Jul 04 2017 11:02
@saifsmailbox98 twas a mistake, I've corrected it. please look at it again.
Saif Ur Rahman
@saifsmailbox98
Jul 04 2017 11:03
why return ?
its not a function
try console.log(myUser);
@nanaowusunyamekye
Finn Pegler
@FinnPegler
Jul 04 2017 11:07

Why is this an infinite loop? The function is trying to remove all elements from the initial array that are of the same value as the following arguments (2,3,5).

function destroyer(arr) {
arr1 = arguments[0];
argLength = arguments.length;
arr2 = [];

for (var i in arr1) {
for (var j = 1; j < argLength; i++) {
if (arr1[i] !== arguments[j]) {
console.log(arguments[i])
arr2.push(arr1[i]);
}
}
}
console.log(arr2);
}

destroyer([3, 5, 1, 2, 2], 2, 3, 5)

Saif Ur Rahman
@saifsmailbox98
Jul 04 2017 11:08
for (var j = 1; j < argLength; i++)
i++ ?
@FinnPegler Also your code will push too many elements.
You are picking an element, if its not 2 pushing it, also if its not 3 pushing it, if its not 5 pushing it.
Output: [ 3, 3, 5, 5, 1, 1, 1, 2, 2, 2, 2 ]
Nana Owusu
@nanaowusunyamekye
Jul 04 2017 11:10
@saifsmailbox98 i've tried console.log(myUser); but it didn't work. The main error its throwing at me is 'unreachable code'
don't know why that is happening
Saif Ur Rahman
@saifsmailbox98
Jul 04 2017 11:10
@nanaowusunyamekye which challenge is that?
Nana Owusu
@nanaowusunyamekye
Jul 04 2017 11:11
@saifsmailbox98 its not a challenge on FCC. Something outside FCC curriculum that i'm trying out
Saif Ur Rahman
@saifsmailbox98
Jul 04 2017 11:11
@nanaowusunyamekye what are the instructions?
Nana Owusu
@nanaowusunyamekye
Jul 04 2017 11:15

@saifsmailbox98
Instructions are

//create a new object with properties matching the arguments passed in.
//return the new object

the test looks like this

describe('newUser(name, email, password)', function() {
  it('should return a new user object with a name, email, and password property that match the arguments', function() {
    var user = {
      name: 'Ben',
      email: 'ben@lambdaschool.com',
      password: 'correcthorsebatterystaple'
    };
    expect(exercises.newUser(user.name, user.email, user.password)).toEqual(user);
    var user = {
      name: 'Austen',
      email: 'austen@lambdaschool.com',
      password: 'password'
    };
    expect(exercises.newUser(user.name, user.email, user.password)).toEqual(user);
  });
});
Saif Ur Rahman
@saifsmailbox98
Jul 04 2017 11:16
@nanaowusunyamekye then
return {
"name" : name,
"email" : email,
"password": password
};
Nana Owusu
@nanaowusunyamekye
Jul 04 2017 11:19
@saifsmailbox98 and where should that block of code go exactly?
Saif Ur Rahman
@saifsmailbox98
Jul 04 2017 11:20
@nanaowusunyamekye inside the function.
@nanaowusunyamekye
function newUser(name, email, password) {
  //create a new object with properties matching the arguments passed in.
  //return the new object

return {
"name" : name,
"email" : email,
"password": password
};        // returning new object

}
Finn Pegler
@FinnPegler
Jul 04 2017 11:23

for (var j = 1; j < argLength; i++)
i++ ?

Thanks. I understand your second point. What did you mean about i++. Is that not the write terminology to iterate upwards by 1 each loop?

Saif Ur Rahman
@saifsmailbox98
Jul 04 2017 11:23
@FinnPegler you have i++, instead of j++
shivam gupta
@shivamg11000
Jul 04 2017 11:24
hey I find stateless component updating a statefull component very unintuitive and messy. Is redux useful here
judgejab
@judgejab
Jul 04 2017 11:27
Hey guys, can someone please give me some pointers as to what I'm doing wrong here?
function translatePigLatin(str) {
  if ((/[aeiou]/).test(str.charAt(0)))
    return str + "way";

  else {
    let char;

    for (let i = 1; i < str.length; i++) {
      char = str.charAt(i);
      if ((/[aeiou]/).test(char)) {
        break;
      }
    }
    return str.substr(char) + str.slice(0, char) + "ay";    
  }
}

translatePigLatin("glove");
Saif Ur Rahman
@saifsmailbox98
Jul 04 2017 11:28
@judgejab only checking for one letter [aeiou]
Dan Couper
@DanCouper
Jul 04 2017 11:28
You need to provide some context. Redux makes some things easier, but you need to add a lot of boilerplate code. It's not just a way to not have to write stateful components
Saif Ur Rahman
@saifsmailbox98
Jul 04 2017 11:28
use + for one or more.
@judgejab
judgejab
@judgejab
Jul 04 2017 11:29
[aeiou]+?
Saif Ur Rahman
@saifsmailbox98
Jul 04 2017 11:30
@judgejab yes
judgejab
@judgejab
Jul 04 2017 11:30
Still doesn't work yet haha
Am I on the right track or should I start over?
wonder
@wonder2991
Jul 04 2017 11:33
what should the return be for 'glove'?
judgejab
@judgejab
Jul 04 2017 11:33
oveglay
Saif Ur Rahman
@saifsmailbox98
Jul 04 2017 11:33
@judgejab you need to pick all the consonants front the front and put it at the end +ay.
judgejab
@judgejab
Jul 04 2017 11:33
I'm getting gloveay
wonder
@wonder2991
Jul 04 2017 11:34
alright
Saif Ur Rahman
@saifsmailbox98
Jul 04 2017 11:34
@judgejab you not not picking gl. Search how to do it.
Finn Pegler
@FinnPegler
Jul 04 2017 11:34
@saifsmailbox98 What an idiot. Thanks!
CamperBot
@camperbot
Jul 04 2017 11:34
finnpegler sends brownie points to @saifsmailbox98 :sparkles: :thumbsup: :sparkles:
:cookie: 706 | @saifsmailbox98 |http://www.freecodecamp.com/saifsmailbox98
judgejab
@judgejab
Jul 04 2017 11:34

I thought that's what I was doing with str.slice(0, char)

By grabbing the start till the first vowel?

Nana Owusu
@nanaowusunyamekye
Jul 04 2017 11:34
Capture.PNG
Saif Ur Rahman
@saifsmailbox98
Jul 04 2017 11:35
@nanaowusunyamekye your code.
Nana Owusu
@nanaowusunyamekye
Jul 04 2017 11:35
@saifsmailbox98 thanks but its still not working. perhaps this image might provide more context
CamperBot
@camperbot
Jul 04 2017 11:35
nanaowusunyamekye sends brownie points to @saifsmailbox98 :sparkles: :thumbsup: :sparkles:
:cookie: 707 | @saifsmailbox98 |http://www.freecodecamp.com/saifsmailbox98
Nana Owusu
@nanaowusunyamekye
Jul 04 2017 11:36
Capture.PNG @saifsmailbox98 maybe this image might provide a little more context
Saif Ur Rahman
@saifsmailbox98
Jul 04 2017 11:37
@nanaowusunyamekye two tt in password
judgejab
@judgejab
Jul 04 2017 11:43
function translatePigLatin(str) {
  //If first letter is a vowel, just add "way"
  if ((/[aeiou]+/).test(str.charAt(0)))
    return str + "way";

  else {
    //if first letter is not a vowel, then loop around and find first vowel
    let char;

    for (let i = 1; i < str.length; i++) {
      char = str.charAt(i);

      // check if letter is vowel
      if ((/[aeiou]+/).test(char)) {
        break;
      }
    }

    //return the vowel till the end + the consonants UP to the vowel + "ay"
    return str.substr(char) + str.slice(0, char) + "ay";    
  }
}

translatePigLatin("glove");
how can I think about this better, @saifsmailbox98
Nana Owusu
@nanaowusunyamekye
Jul 04 2017 11:44
@saifsmailbox98 have this now but i'm still getting uncreachable code detected
function newUser(name, email, password) {
  //create a new object with properties matching the arguments passed in.
  //return the new object

  // this.name = name;
  // this.email = email;
  // this.password = password;

  return {
  'name' : name,
  'email' : email,
  'password': password
};

  var myUser = new newUser('Ben', 'ben@lambdaschool.com', 'correcthorsebatterystaple');
  return myUser;
}
Saif Ur Rahman
@saifsmailbox98
Jul 04 2017 11:44

put these two lines

  var myUser = new newUser('Ben', 'ben@lambdaschool.com', 'correcthorsebatterystaple');
  return myUser;

outside the function

function newUser(name, email, password) {
  //create a new object with properties matching the arguments passed in.
  //return the new object
  return {
  'name' : name,
  'email' : email,
  'password': password
};
}

  var myUser = new newUser('Ben', 'ben@lambdaschool.com', 'correcthorsebatterystaple');
  return myUser;
EpicTriffid
@EpicTriffid
Jul 04 2017 11:46
Hi all. So my code (https://codepen.io/EpicTriffid/pen/xrjxVE) is here, and Im trying to control the speed of the fadeIn in my Javascript, but no matter what I do, the #temp element will pop in regardless of what speed i put. Any idea?
Saif Ur Rahman
@saifsmailbox98
Jul 04 2017 11:46
@judgejab slice(0, char), what is char a number? its the first vowel.
judgejab
@judgejab
Jul 04 2017 11:46
yeah, it should be the index of the first vowel
Saif Ur Rahman
@saifsmailbox98
Jul 04 2017 11:47
 char = str.charAt(i);
judgejab
@judgejab
Jul 04 2017 11:47
oh crap
Saif Ur Rahman
@saifsmailbox98
Jul 04 2017 11:47
char is a character
judgejab
@judgejab
Jul 04 2017 11:47
sorry yes
function translatePigLatin(str) {
  //If first letter is a vowel, just add "way"
  if ((/[aeiou]+/).test(str.charAt(0)))
    return str + "way";

  else {
    //if first letter is not a vowel, then loop around and find first vowel
    let char;
    let firstVowelIndex;

    for (let i = 1; i < str.length; i++) {
      char = str.charAt(i);

      // check if letter is vowel
      if ((/[aeiou]+/).test(char)) {
        firstVowelIndex = str.indexOf(char);
        break;
      }
    }

    //return the vowel till the end + the consonants UP to the vowel + "ay"
    return str.substr(firstVowelIndex) + str.slice(0, firstVowelIndex) + "ay";    
  }
}

translatePigLatin("glove");

That is some UGLY code. I'm ashamed lol

Thank you @saifsmailbox98

CamperBot
@camperbot
Jul 04 2017 11:50
judgejab sends brownie points to @saifsmailbox98 :sparkles: :thumbsup: :sparkles:
:cookie: 708 | @saifsmailbox98 |http://www.freecodecamp.com/saifsmailbox98
Saif Ur Rahman
@saifsmailbox98
Jul 04 2017 11:50
@nanaowusunyamekye :point_up: July 4, 2017 5:14 PM
@judgejab try str.match(/^[^aeiou]+/); to capture the consonants
judgejab
@judgejab
Jul 04 2017 11:53
dang, I didn't even think of that lol
wonder
@wonder2991
Jul 04 2017 11:55
function translatePigLatin(str) {
  var res=[];
  var regex=/[aeiou]/;
  if(regex.test(str.charAt(0)))
    return str+'way';
  str = str.split('');
  for(var i=0;i<str.length;i++){
  while(!regex.test(str[0])){
      res.push(str.shift());
    } 
  } 
  return str.concat(res).join('')+'ay'; 
}
Nana Owusu
@nanaowusunyamekye
Jul 04 2017 12:04
console.PNG
Saif Ur Rahman
@saifsmailbox98
Jul 04 2017 12:05
@nanaowusunyamekye what do the exercise expects?
Nana Owusu
@nanaowusunyamekye
Jul 04 2017 12:05
console.PNG@saifsmailbox98 got it. its outputting correctly when i run it in a different file but not the 'exercise' file
judgejab
@judgejab
Jul 04 2017 12:09
I really struggle with RegExps, how would you recommend I get better guys?
wonder
@wonder2991
Jul 04 2017 12:11
mdn
Nana Owusu
@nanaowusunyamekye
Jul 04 2017 12:16

@saifsmailbox98 I have this now, and the test passed

function newUser(name, email, password) {
  //create a new object with properties matching the arguments passed in.
  //return the new object

  return {
  'name' : name,
  'email' : email,
  'password': password
};
}

if you can, please explain to me what's happening here. haven't seen an object been instantiated like this before.

Saif Ur Rahman
@saifsmailbox98
Jul 04 2017 12:17
@nanaowusunyamekye isn't this same as what I posted?
judgejab
@judgejab
Jul 04 2017 12:18
awesome, thank you, @wonder2991
CamperBot
@camperbot
Jul 04 2017 12:18
judgejab sends brownie points to @wonder2991 :sparkles: :thumbsup: :sparkles:
:cookie: 383 | @wonder2991 |http://www.freecodecamp.com/wonder2991
Saif Ur Rahman
@saifsmailbox98
Jul 04 2017 12:18
@nanaowusunyamekye
function newUser(name, email, password) {
  //create a new object with properties matching the arguments passed in.
  //return the new object

  var tempObj = {
  'name' : name,
  'email' : email,
  'password': password
};

return tempObj;
}
instead of saving the new object in a variable, directly return it.
Nana Owusu
@nanaowusunyamekye
Jul 04 2017 12:19
@saifsmailbox98 it is, but the mistake i made was thinking, I had to create a new object by doing var myUser = new newUser() .................. Apparently, that wasn't needed.
Saif Ur Rahman
@saifsmailbox98
Jul 04 2017 12:20
@nanaowusunyamekye the instructions were to only create a function that returns the object?
:joy:
Nana Owusu
@nanaowusunyamekye
Jul 04 2017 12:21
@saifsmailbox98 :smile: thanks :+1:
CamperBot
@camperbot
Jul 04 2017 12:21
nanaowusunyamekye sends brownie points to @saifsmailbox98 :sparkles: :thumbsup: :sparkles:
:warning: nanaowusunyamekye already gave saifsmailbox98 points
Saif Ur Rahman
@saifsmailbox98
Jul 04 2017 12:21
@nanaowusunyamekye yw
judgejab
@judgejab
Jul 04 2017 12:27
Anybody know if we work through the Beta freecodecamp stuff, that when it's released to the main program...will we keep all out progress? Will it be merged?
judgejab
@judgejab
Jul 04 2017 12:29
dang, I need to get better at google, thank you guys
oh, but it only says resubmitting the projects...not necessarily the challenges?
Saif Ur Rahman
@saifsmailbox98
Jul 04 2017 12:31
no guarantees, read this issue :freeCodeCamp/freeCodeCamp#13462
@judgejab
judgejab
@judgejab
Jul 04 2017 12:34
okay thank you
Sweet Coding :)
@SweetCodingInc
Jul 04 2017 12:43
@alexjschiffer : Alright. Will take a look after some time.. A bit busy now :)
Nerijus
@neneriukas
Jul 04 2017 12:43
Hello. I'm currently at Intermediate Algorithm Scripting -> Drop It. Could someone explain me please why
dropElements([1, 2, 3, 9, 2], function(n) {return n > 2;}) should return [3, 9, 2] ? I mean 2 is not > 2, so why it should return 2 here? or another one:
dropElements([0, 1, 0, 1], function(n) {return n === 1;}) should return [1, 0, 1]. As per my understanding it should only return [1,1] :/
Sweet Coding :)
@SweetCodingInc
Jul 04 2017 12:45
@neneriukas : You misunderstood it. Read instructions again
Saif Ur Rahman
@saifsmailbox98
Jul 04 2017 12:45
@neneriukas you have to return the array from the point where the function passed returns true for the first element.
Sweet Coding :)
@SweetCodingInc
Jul 04 2017 12:46

Drop the elements of an array (first argument), starting from the front, until the predicate (second argument) returns true.

You need to drop all the elements until the func returns true. You should retain remaining elements of the array.

Saif Ur Rahman
@saifsmailbox98
Jul 04 2017 12:47
@neneriukas dropElements([0, 1, 0, 1], function(n) {return n === 1;})
is 0 === 1 ? no!
is 1 ===1 ? yes, return from here [1,0,1]
Nerijus
@neneriukas
Jul 04 2017 12:47
ahh thanks guys! I get it now. my bad
Sweet Coding :)
@SweetCodingInc
Jul 04 2017 12:48

@saifsmailbox98 : Again. You need to drop the elements until the predicate becomes true.

In case of [0, 1, 0, 1]

For 0 at index 0, 0 === 1 is false, drop it.
for 1 at index 1 1 === 1 is true, so return everything index 1 onward.

Saif Ur Rahman
@saifsmailbox98
Jul 04 2017 12:49
@SweetCodingInc thats what I meant.
Sweet Coding :)
@SweetCodingInc
Jul 04 2017 12:50
@saifsmailbox98 Sorry.. I intended to tag @neneriukas
Saif Ur Rahman
@saifsmailbox98
Jul 04 2017 12:50
:) no prob.
Michiel
@MichielHuijse
Jul 04 2017 12:58
I am currently working on the wikipedia viewer and I am wrestling with the api and the wikipedia sandbox. What I find strange is that there is no such thin as action search when making a http request in the sandbox. Can someone explain how I should make the request or where I can find information on making a search request?
shivam gupta
@shivamg11000
Jul 04 2017 13:13
'https://en.wikipedia.org/w/api.php?action=opensearch&search=' + qeury + '&callback=?'
use this @MichielHuijse
h1tag
@h1tag
Jul 04 2017 13:13
@MichielHuijse there's a query and opensearch actions for searching. But I found that opensearch is better for this project (the object this action returns has the data easily accessible)
shivam gupta
@shivamg11000
Jul 04 2017 13:14
you have to put your query keyword
@MichielHuijse
Kirill
@Kirill255
Jul 04 2017 13:14
Can somebody tell me why my code doesn't work when I load the page, but it works when I click the button? I think this is related to the scope, but I don't know how to fix it. Don't look at the appearance, now I'm just trying to correctly display the data.
https://codepen.io/kirill255/pen/QgrReB?editors=0010
Michiel
@MichielHuijse
Jul 04 2017 13:15
@shivamg11000 and @h1tag thanks, so action opensearch was what I was looking for thanks :)
CamperBot
@camperbot
Jul 04 2017 13:15
michielhuijse sends brownie points to @shivamg11000 and @h1tag :sparkles: :thumbsup: :sparkles:
:cookie: 890 | @h1tag |http://www.freecodecamp.com/h1tag
:cookie: 355 | @shivamg11000 |http://www.freecodecamp.com/shivamg11000
h1tag
@h1tag
Jul 04 2017 13:21
@Kirill255 call your getWeather() inside your getLocation(), after you get the location data
This message was deleted
this happens because the location data wasn't available for getWeather at load time
so, this way you make sure it's called when the location data is available
Kirill
@Kirill255
Jul 04 2017 13:25
@h1tag it works, thanks a lot :+1:
CamperBot
@camperbot
Jul 04 2017 13:25
kirill255 sends brownie points to @h1tag :sparkles: :thumbsup: :sparkles:
:cookie: 891 | @h1tag |http://www.freecodecamp.com/h1tag
Michiel
@MichielHuijse
Jul 04 2017 13:47
@h1tag or @shivamg11000 I still get a cors problem with this request, why? XMLHttpRequest cannot load https://en.wikipedia.org/w/api.php?action=opensearch&format=json&origin=Access-Control-Allow-Origin&search=Te. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. The response had HTTP status code 403.
I meen, I set the "origin" to "Acces-Control-Allow-Origin" since it is cross origin resource sharing in this request
Michiel
@MichielHuijse
Jul 04 2017 13:59
I think I forgot the callback at the end of the request, however 'data' stays undefined$.getJSON( "https://en.wikipedia.org/w/api.php?action=opensearch&format=jsonp&origin=Access-Control-Allow-Origin&search=jansmit&callback=?", function( data ) { console.log(data); });
Stephen James
@sjames1958gm
Jul 04 2017 14:21
@MichielHuijse try using origin=* to circumvent cors
@MichielHuijse IT is the server that has to set the correct headers not the client
Derek B. McIntire
@derekbmcintire
Jul 04 2017 14:22
Hey all, not sure if this is a jquery, javascript or css issue, but I'm working on my twitch API app and the rows I'm appending to my html have a weird margin padding issue where htey are off to the left. I noticed this before I had any styling at all because the usernames were cut off on the left of the screen. Anyone know what is going on? Here's my pen - https://codepen.io/derekbmcintire/pen/eRKOvj?editors=1111
Stephen James
@sjames1958gm
Jul 04 2017 14:22
@MichielHuijse "https://en.wikipedia.org/w/api.php?action=opensearch&format=json&origin=Access-Control-Allow-Origin&search=Te&origin=*"
Diego Mayer
@Chrono79
Jul 04 2017 14:23
@MichielHuijse simplify the url https://en.wikipedia.org/w/api.php?action=opensearch&search=whatever&callback=?
MadsSN
@MadsSN
Jul 04 2017 14:26
Does anyone have a suggestion for eventtriggering similar to onchange on a input field?
Another question, any suggestion for how to create a button that does the equivalent of ctrl+v
Michiel
@MichielHuijse
Jul 04 2017 14:26
thanks @sjames1958gm and @Chrono79 so in the example of @Chrono79 you are not using jsonp however it is another domain I am retrieving an object from howcome it still works and should there be a callback=?
CamperBot
@camperbot
Jul 04 2017 14:26
michielhuijse sends brownie points to @sjames1958gm and @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4456 | @chrono79 |http://www.freecodecamp.com/chrono79
:star2: 7985 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
MadsSN
@MadsSN
Jul 04 2017 14:28
I think oninput might do the trick :)
Stephen James
@sjames1958gm
Jul 04 2017 14:28
@derekbmcintire You are getting a -15 margin from bootstrap for some reason their grid framework
@derekbmcintire you can override with margin-left: 0 in your testrow class
Diego Mayer
@Chrono79
Jul 04 2017 14:29
Stephen James
@sjames1958gm
Jul 04 2017 14:30
Do you know if wikipedia supports jsonp?
Derek B. McIntire
@derekbmcintire
Jul 04 2017 14:30
@sjames1958gm yeah I noticed I could override it with the margin-left: 0 I just couldn't understand why it was happening. Thanks though!
CamperBot
@camperbot
Jul 04 2017 14:30
derekbmcintire sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7986 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jul 04 2017 14:31
I used the style inspector and found -15 in some bootsrap grid framework file
Michiel
@MichielHuijse
Jul 04 2017 14:32
Actually I thought it was the only way to do a request with jsonp but it isn't.
Michiel
@MichielHuijse
Jul 04 2017 14:38
@Chrono79 thanks!
CamperBot
@camperbot
Jul 04 2017 14:38
michielhuijse sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: michielhuijse already gave chrono79 points
Diego Mayer
@Chrono79
Jul 04 2017 14:38
:+1:
Marcos D
@mdanilo
Jul 04 2017 14:42
hello, can someone help me? Show the local weather
h1tag
@h1tag
Jul 04 2017 14:43
@mdanilo sure
Marcos D
@mdanilo
Jul 04 2017 14:45
My temperature shows the three numbers for example -143º ... I would like it to only show the first two ... getting thus -14º - !!!
Marianissimus
@Marianissimus
Jul 04 2017 14:48
@mdanilo like var newtemp = temp[0]+temp[1]?
h1tag
@h1tag
Jul 04 2017 14:48
@mdanilo you mean you want to convert the temperature unit (from fahrenheit to celsius, for example)?
Marcos D
@mdanilo
Jul 04 2017 14:50
My Cº is 143º, in fact it should appear 14º only two numbers
h1tag
@h1tag
Jul 04 2017 14:51
hmmm
Marianissimus
@Marianissimus
Jul 04 2017 14:51
@mdanilo if your C is 143, then it must be getting the value from Venus...
h1tag
@h1tag
Jul 04 2017 14:51
:laughing:
@mdanilo what API are you using?
Marcos D
@mdanilo
Jul 04 2017 14:53
openweathermap
Johnny
@JohnnyBizzel
Jul 04 2017 14:54

@mdanilo if your C is 143, then it must be getting the value from Venus...

He said -143 , must be mars.

Marcos D
@mdanilo
Jul 04 2017 14:54
143º*
h1tag
@h1tag
Jul 04 2017 14:55
@mdanilo and you're developing locally, because this API doesn't work on Codepen
Johnny
@JohnnyBizzel
Jul 04 2017 14:55
@mdanilo I would try another API!
Marcos D
@mdanilo
Jul 04 2017 14:56
Does not really work without code
Johnny
@JohnnyBizzel
Jul 04 2017 14:56
@mdanilo what does that mean?
@mdanilo all api's can be tested with just a browser
a27-suryansh
@a27-suryansh
Jul 04 2017 14:59
Hi i need little bit help with Twitch View can someone please help?
https://codepen.io/a27suryansh/pen/eRWpKm
I am not able to show Correct Status of the channel
All channels are either going offline or online
I am not able to fetch exclusive status of each channel
h1tag
@h1tag
Jul 04 2017 15:07
@a27-suryansh if the channel online, it has a status property. You have to log the objects you're receiving from the API and search the online ones for this property to figure out how to access it
Michiel
@MichielHuijse
Jul 04 2017 15:10
Hi where is a good tutorial on how to use the console for javascript. I want to do some things with the json request in the console.. for example I would assume this works: console.log(JSON.stringify(data));
Nitin Sahu
@globefire
Jul 04 2017 15:10

function palindrome(str) {
// Good luck!
var a = [];
a = str.split('');
var i;
var b = [];
var c = 0;
for( i = a.length - 1; i >= 0; i--){
b = a[i];
}

for( j = 0; j < a.length; j++){
if(a[i] != b[j]){
c++;
}
}
if(c != 0){
return false;
}
else{
return true;
}
}

palindrome("eye");

what is d error in this code ?
teevik
@teevik
Jul 04 2017 15:10
'''
CamperBot
@camperbot
Jul 04 2017 15:10
:bulb: to format code use backticks! ``` more info
a27-suryansh
@a27-suryansh
Jul 04 2017 15:11
@h1tag I have two api's
1) https://wind-bow.gomix.me/twitch-api/channels/ (This one provides details of all the channels but doesn't provide status)
2) https://wind-bow.gomix.me/twitch-api/streams/ (This one provides details of only the online channels but provides status)
I am not sure how to use both apis at once @h1tag
Nitin Sahu
@globefire
Jul 04 2017 15:12
function palindrome(str) {
  // Good luck!
  var a = [];
  a = str.split('');
  var i;
  var b = [];
  var c = 0;
  for( i = a.length - 1; i >= 0; i--){
    b = a[i];
  }

  for( j = 0; j < a.length; j++){
    if(a[i] != b[j]){
      c++;
    }
  }
    if(c != 0){
  return false;
    }
    else{ 
      return true;
    }
}



palindrome("eye");
anyone ?
teevik
@teevik
Jul 04 2017 15:12
b = a[i];
Are you getting any errors or is it just not working?
Nitin Sahu
@globefire
Jul 04 2017 15:13
ok ok
h1tag
@h1tag
Jul 04 2017 15:13
@a27-suryansh I think both of them provide status, check the documentation
Nitin Sahu
@globefire
Jul 04 2017 15:13
lol :laughing:
still not happening @teevik
teevik
@teevik
Jul 04 2017 15:14
1 sec
a27-suryansh
@a27-suryansh
Jul 04 2017 15:15
@h1tag I have checked it but Channels api doesn't provide stream status it provides some other status
h1tag
@h1tag
Jul 04 2017 15:16
check the example there ^
a27-suryansh
@a27-suryansh
Jul 04 2017 15:16
@h1tag it gives status like this "status": "Struggle Bus 5: The Fight to Stay Alive",
@h1tag how do i know if channel is online or offline
h1tag
@h1tag
Jul 04 2017 15:17
Ok, this is the status
a27-suryansh
@a27-suryansh
Jul 04 2017 15:17
@h1tag it will still give the same status
Hopper Kremer
@hopperkremer
Jul 04 2017 15:17
https://codepen.io/HopperKremer/pen/gRmddY
Hi guys, why won't clearInterval work at the end of my JS?
h1tag
@h1tag
Jul 04 2017 15:18
@a27-suryansh you're already doing this if (loadData.stream === null) {, which checks if the stream is online or offline
a27-suryansh
@a27-suryansh
Jul 04 2017 15:18
yes but how do i update the status of that channel in HTML @h1tag
h1tag
@h1tag
Jul 04 2017 15:19
@a27-suryansh you confused me, what do you mean by "status"?
a27-suryansh
@a27-suryansh
Jul 04 2017 15:20

@h1tag

{
    "stream": null,
    "_links": {
        "self": "https://api.twitch.tv/kraken/streams/freecodecamp",
        "channel": "https://api.twitch.tv/kraken/channels/freecodecamp"
    }
}

This is the response from streams api

teevik
@teevik
Jul 04 2017 15:20

@globefire With

for( i = a.length - 1; i >= 0; i--){
    b[i] = a[i];
  }

you're not reversing the array

a27-suryansh
@a27-suryansh
Jul 04 2017 15:20
@h1tag
And this is the response from channels api
{
    "mature": false,
    "status": "Some GoLang Today #go #golang #youtube",
    "broadcaster_language": "en",
    "display_name": "FreeCodeCamp",
    "game": "Creative",
    "language": "en",
    "_id": 79776140,
    "name": "freecodecamp",
    "created_at": "2015-01-14T03:36:47Z",
    "updated_at": "2017-07-04T14:32:29Z",
    "partner": false,
    "logo": "https://static-cdn.jtvnw.net/jtv_user_pictures/freecodecamp-profile_image-d9514f2df0962329-300x300.png",
    "video_banner": "https://static-cdn.jtvnw.net/jtv_user_pictures/freecodecamp-channel_offline_image-b8e133c78cd51cb0-1920x1080.png",
    "profile_banner": "https://static-cdn.jtvnw.net/jtv_user_pictures/freecodecamp-profile_banner-6f5e3445ff474aec-480.png",
    "profile_banner_background_color": null,
    "url": "https://www.twitch.tv/freecodecamp",
    "views": 188981,
    "followers": 10973,
    "_links": {
        "self": "https://api.twitch.tv/kraken/channels/freecodecamp",
        "follows": "https://api.twitch.tv/kraken/channels/freecodecamp/follows",
        "commercial": "https://api.twitch.tv/kraken/channels/freecodecamp/commercial",
        "stream_key": "https://api.twitch.tv/kraken/channels/freecodecamp/stream_key",
        "chat": "https://api.twitch.tv/kraken/chat/freecodecamp",
        "features": "https://api.twitch.tv/kraken/channels/freecodecamp/features",
        "subscriptions": "https://api.twitch.tv/kraken/channels/freecodecamp/subscriptions",
        "editors": "https://api.twitch.tv/kraken/channels/freecodecamp/editors",
        "teams": "https://api.twitch.tv/kraken/channels/freecodecamp/teams",
        "videos": "https://api.twitch.tv/kraken/channels/freecodecamp/videos"
    },
    "delay": null,
    "banner": null,
    "background": null
}
If you see both are providing status but i want the status from streams api @h1tag
h1tag
@h1tag
Jul 04 2017 15:21
@a27-suryansh OK, then go get it ;)
a27-suryansh
@a27-suryansh
Jul 04 2017 15:21
@h1tag How do i update it in the HTML I am not able to figure it out...
h1tag
@h1tag
Jul 04 2017 15:23
@a27-suryansh is this your code? Because you're already updating the html using $(".online-result").html(allList);
so this how you update the html
akilesh
@akileshv
Jul 04 2017 15:23
how to convert nested table to csv
a27-suryansh
@a27-suryansh
Jul 04 2017 15:24
Yes @h1tag I am updating like this
 for (var j = 0; j < channels.length; j++) {
    // Updates allList Variable
    $.getJSON(
      "https://wind-bow.gomix.me/twitch-api/channels/" +
      channels[j] +
      "?callback=?",
      function(onlineContent) {
        allList += "<div class='channel-row'>";
        allList += "<div class='channel-logo'>";
        allList += "<img src='" + onlineContent.logo + "' />";
        allList += "</div>";
        allList += "<div class='channel-name'>"
        allList +=onlineContent.display_name
        allList +="</div>"
        allList += "<div class='status-text'>"
        allList += status;
        allList += "</div>"
        allList += "</div>";
        $(".online-result").html(allList);
      }
    );
  }
teevik
@teevik
Jul 04 2017 15:25
@globefire You also need to filter out non-alphanumerical numbers and make it lowercase
I got it working with your code after i did that
PipsChips
@PipsChips
Jul 04 2017 15:27
Hi! Not a FCC stuff, but... is there anyone who knows how to display a PDF file after I've decryped/decoded it as a string...?
Hopper Kremer
@hopperkremer
Jul 04 2017 15:36
https://codepen.io/HopperKremer/pen/gRmddY
Hi guys, why won't clearInterval work at the end of my JS?
Russell Morgan
@itskingruss
Jul 04 2017 15:37
Morning folks
Hopper Kremer
@hopperkremer
Jul 04 2017 15:41
NVM
Caleb Pearman
@capearman
Jul 04 2017 15:53
Hey guys, why can't I get my function to display text on the webpage? https://codepen.io/capearman/pen/dRZXKx?editors=1011
teevik
@teevik
Jul 04 2017 15:55
nvm, 1 sec
Yeah, it's somehow null
paraEl1
Caleb Pearman
@capearman
Jul 04 2017 16:02
I can't figure out why it's null :worried:
Zyberg
@Zyberg
Jul 04 2017 16:03
@capearman looking into it
Caleb Pearman
@capearman
Jul 04 2017 16:03
@Zyberg thanks :smile:
CamperBot
@camperbot
Jul 04 2017 16:03
capearman sends brownie points to @zyberg :sparkles: :thumbsup: :sparkles:
:cookie: 268 | @zyberg |http://www.freecodecamp.com/zyberg
Zyberg
@Zyberg
Jul 04 2017 16:05
@capearman what exactly doesn't work? I corrected some things, but it works as expected - outputs 'quote' to website
teevik
@teevik
Jul 04 2017 16:05
<div></div id = "quote"> Id in end, not start
Zyberg
@Zyberg
Jul 04 2017 16:07
@capearman and your function accessEl should have no parameters. You define your testArr as a global variable, so just write: acessEl() everywhere.
@capearman and consider using an array of objects for storing the quotes. It would make programming part not so confusing ;)
Finn Pegler
@FinnPegler
Jul 04 2017 16:08
Am I crazy or is the explanation for the basic solution explaining a different solution? https://forum.freecodecamp.org/t/freecodecamp-algorithm-challenge-guide-caesars-cipher/16003
Zyberg
@Zyberg
Jul 04 2017 16:10
@FinnPegler everything seems alright to me. What do you find confusing?
Caleb Pearman
@capearman
Jul 04 2017 16:10
@Zyberg for some reason I couldn't get the console.log() to work without putting the array as a parameter
slertka
@slertka
Jul 04 2017 16:10
anyone know why i can't call my global variable outside of the function?
Zyberg
@Zyberg
Jul 04 2017 16:11
@capearman well, you shouldn't use console.log in such way as you use it now ;) What were you trying to accomplish with it?
slertka
@slertka
Jul 04 2017 16:11
i can get hte correct output if i console.log within the makeURL function, but not if i call outside the function :-/
Finn Pegler
@FinnPegler
Jul 04 2017 16:11
@Zyberg Where's the string variable nstr that the solution talks about?
Also where is the for loop?
Caleb Pearman
@capearman
Jul 04 2017 16:12
@Zyberg I use it to test my function as I go along
Zyberg
@Zyberg
Jul 04 2017 16:12
@FinnPegler oh! I thought you were talking about the code comments. Yeah, you are right. Though, code comments explain everything alright.
Finn Pegler
@FinnPegler
Jul 04 2017 16:13
Ok I'll stick to the code comments, thanks!
Zyberg
@Zyberg
Jul 04 2017 16:13
@capearman writing console.log(functionName()); outputs whatever the function return value is.
In your case you don't have any return value, so put console.log() inside the function. For example:
console.log(quoteDiv);
@slertka could you explain what doesn't work a little bit more? What are you trying to do?
Caleb Pearman
@capearman
Jul 04 2017 16:16
@Zyberg I gotcha. But I usually use it to text the value of my variables. I'll set the value of a variable and then return the variable to make sure that it works.
@Zyberg but what do you mean by using an array of objects?
slertka
@slertka
Jul 04 2017 16:17
@Zyberg i want to call the API using the lat and long of the current position. I am able to create the custom URL in my makeURL function, but it doesn't assign the value to the global variable
Zyberg
@Zyberg
Jul 04 2017 16:17

@capearman just put the console.log() near the variable like:

var testArr = [[1,2],[3,4]];
console.log(testArr);

What I mean by array of objects:

var testArr = [
{author: "John Smith",
quote:"Life is good!"},
{author:"Me",
quote:"Code is good!}
]
shivam gupta
@shivamg11000
Jul 04 2017 16:19
@slertka hey
slertka
@slertka
Jul 04 2017 16:19
@shivamg11000 still can't figure it out!!
Zyberg
@Zyberg
Jul 04 2017 16:19
@slertka well, put console.log inside ShowPosition
Sweet Coding :)
@SweetCodingInc
Jul 04 2017 16:20
@slertka : Asynchronous issues :D
Zyberg
@Zyberg
Jul 04 2017 16:20
@SweetCodingInc what asynchronous is in the code tho? The way slertka is creating the url isn't asynchronous.
slertka
@slertka
Jul 04 2017 16:21
@Zyberg , did that, and was able to get the correct output in the console
Sweet Coding :)
@SweetCodingInc
Jul 04 2017 16:21
Secondly you're not calling your functions
Caleb Pearman
@capearman
Jul 04 2017 16:21
@Zyberg alright, so how would I access that randomly?
Zyberg
@Zyberg
Jul 04 2017 16:22
@SweetCodingInc he is calling them after the user provides geolocation ;)
teevik
@teevik
Jul 04 2017 16:22
@capearman Just like you did previously
Zyberg
@Zyberg
Jul 04 2017 16:22
@capearman the same way! It is still an Array. However, now you can have a much nicer interface:
testArr[ri]["author] would give you the author of the quote.
Sweet Coding :)
@SweetCodingInc
Jul 04 2017 16:23
@slertka Just call your getCurrentWeather after makeURL
Caleb Pearman
@capearman
Jul 04 2017 16:23
@Zyberg oh, alright. Thanks again man. You've been a great help
CamperBot
@camperbot
Jul 04 2017 16:23
capearman sends brownie points to @zyberg :sparkles: :thumbsup: :sparkles:
:warning: capearman already gave zyberg points
Sweet Coding :)
@SweetCodingInc
Jul 04 2017 16:24
function showPosition(position) {
    lat = position.coords.latitude;
    long = position.coords.longitude;
    makeURL();
    getCurrentWeather();
    console.log(urlAPI);
  }
Zyberg
@Zyberg
Jul 04 2017 16:24
@camperbot no problem, happy to help :)
Sweet Coding :)
@SweetCodingInc
Jul 04 2017 16:24
@Zyberg :+1: I see.. May be I was looking at older pen
Zyberg
@Zyberg
Jul 04 2017 16:24
@SweetCodingInc that's alright :)
slertka
@slertka
Jul 04 2017 16:27
omg @SweetCodingInc thank you so much
CamperBot
@camperbot
Jul 04 2017 16:27
slertka sends brownie points to @sweetcodinginc :sparkles: :thumbsup: :sparkles:
:cookie: 66 | @sweetcodinginc |http://www.freecodecamp.com/sweetcodinginc
slertka
@slertka
Jul 04 2017 16:27
so simple
Pagnito
@Pagnito
Jul 04 2017 16:28
can anyone help me with some simple node code?
Zyberg
@Zyberg
Jul 04 2017 16:28
@Pagnito bring it on
Pagnito
@Pagnito
Jul 04 2017 16:29
ok so i cant see any of the two function being called, and i dont know what through2 does, and i cant see how alot of these methods are connected
var through = require('through2');
var stream = through(write, end);
function write(buffer, encoding, next){
    this.push(buffer.toString().toUpperCase());
    next();
}
function end (done){
    done();
}
process.stdin.pipe(stream).pipe(process.stdout);
Zyberg
@Zyberg
Jul 04 2017 16:31
@pagnito well, through2 is one of these: https://www.npmjs.com/browse/keyword/through2
Pagnito
@Pagnito
Jul 04 2017 16:31
yea i saw that, but all those are through2-map or conact
etc
but what about through2 itself?
Zyberg
@Zyberg
Jul 04 2017 16:32
@Pagnito depends on where you found this code.
Sweet Coding :)
@SweetCodingInc
Jul 04 2017 16:32
@slertka :+1:
Zyberg
@Zyberg
Jul 04 2017 16:32
@Pagnito there could be another file written with name 'through2.js'
h1tag
@h1tag
Jul 04 2017 16:32
@Pagnito just googled "through2 npm": https://www.npmjs.com/package/through2
shivam gupta
@shivamg11000
Jul 04 2017 16:33
goodbye world
Zyberg
@Zyberg
Jul 04 2017 16:33
Bingo!
shivam gupta
@shivamg11000
Jul 04 2017 16:33
:wave:
Sweet Coding :)
@SweetCodingInc
Jul 04 2017 16:33
@Pagnito have you installed through2?
Pagnito
@Pagnito
Jul 04 2017 16:33
yea i have
the code is passing me the challenge
its just i dont wanna move on until i understand how exactly this code is working
like, why arent any of the function being called
and what is 'this' in this code
like which element does it hold
Flashtzu
@Flashtzu
Jul 04 2017 16:35

function slasher(arr, howMany) {
var answer = [];
answer.push(arr.slice(howMany));
return answer;
}

slasher(["burgers", "fries", "shake"], 1);
// should return ["fries","shake"].

my code appears to work, but the website wont say correct and let me move on
any ideas why?
Sweet Coding :)
@SweetCodingInc
Jul 04 2017 16:35

@Pagnito This line - > process.stdin.pipe(stream).pipe(process.stdout);

Assuming you understand streams in node, this will listen for the event stdin (user input via standard buffer)

h1tag
@h1tag
Jul 04 2017 16:36
@Flashtzu what's the challenge name?
Sweet Coding :)
@SweetCodingInc
Jul 04 2017 16:36
when you receive the event, your write function will be called. And when input ends, end function will be called
Flashtzu
@Flashtzu
Jul 04 2017 16:36
slasher flick
my thought is that i didnt use splice
Fredrik Strand Oseberg
@FredrikOseberg
Jul 04 2017 16:36
Can you link?
Pagnito
@Pagnito
Jul 04 2017 16:36
@SweetCodingInc why do we need an end function?
Flashtzu
@Flashtzu
Jul 04 2017 16:36
but i dont see a need for it
phuzisham
@phuzisham
Jul 04 2017 16:36
Having trouble with the mutations problem. For some reason I’m passing all tests except that (“hello”, “hey”) is passing true when it should be false. But in all other cases it works. Any ideas?

function mutation(arr) {
  var word0 = arr[0].toLowerCase();
  var word1 = arr[1].toLowerCase();

  for (var i = 0; i < word0.length; i++) {
    if (word0.indexOf(word1[i]) === -1) {
      return false;
    } else {
      return true;
    }
  }
}

mutation(["hello", "hey"]);
Sweet Coding :)
@SweetCodingInc
Jul 04 2017 16:37
this refers to the through instance. (NOTE : I never used this library but assuming it is developed in a standard way, this "should" refer to the through instance)
kumquatfelafel
@kumquatfelafel
Jul 04 2017 16:37
@Flashtzu pushing the sliced portion is no good.
slice returns an array.
Pagnito
@Pagnito
Jul 04 2017 16:37
@SweetCodingInc var stream = through(write, end); what about this line
kumquatfelafel
@kumquatfelafel
Jul 04 2017 16:37
So when you push it, that would give you an array inside an array.
Pagnito
@Pagnito
Jul 04 2017 16:38
so are those two arguments the functions?
Sweet Coding :)
@SweetCodingInc
Jul 04 2017 16:38
@Pagnito It will create through instace with 2 event handlers. write for input in progress and end for input done
Zyberg
@Zyberg
Jul 04 2017 16:38
@phuzisham exclude else from the for loop as the loop will break after the first charecter.
for (var i = 0; i < word0.length; i++) {
    if (word0.indexOf(word1[i]) === -1) {
      return false;
    }}
// if all characters have passed the loop, then it is true
      return true;
Sweet Coding :)
@SweetCodingInc
Jul 04 2017 16:39

@Pagnito

so are those two arguments the functions?

Yes, from the look of it, it appears to me that through constructor takes two functions as argument

Flashtzu
@Flashtzu
Jul 04 2017 16:40
im confused, isnt my answer supposed to be an array?
Pagnito
@Pagnito
Jul 04 2017 16:40
process.stdin.pipe(stream).pipe(process.stdout); is this part calling stream?
kumquatfelafel
@kumquatfelafel
Jul 04 2017 16:40
@Flashtzu Just an array. Not a 2d array.
Flashtzu
@Flashtzu
Jul 04 2017 16:40
OO hmm ok
thank you
kumquatfelafel
@kumquatfelafel
Jul 04 2017 16:40
When you take an array, and you push an array onto it, becomes 2d array
Sweet Coding :)
@SweetCodingInc
Jul 04 2017 16:40
@Pagnito : it is not calling it per say. It is just assigning stream as an event handler for stdin buffer
stdin buffer is the one which will actually call them
Pagnito
@Pagnito
Jul 04 2017 16:41
so once the input is made
that calls it?
Sweet Coding :)
@SweetCodingInc
Jul 04 2017 16:41
yes
phuzisham
@phuzisham
Jul 04 2017 16:41
@Zyberg I did that but same thing is happening. Passes on every test except (“hello”, “hey”)
Pagnito
@Pagnito
Jul 04 2017 16:41
@SweetCodingInc thanks
CamperBot
@camperbot
Jul 04 2017 16:41
pagnito sends brownie points to @sweetcodinginc :sparkles: :thumbsup: :sparkles:
:cookie: 67 | @sweetcodinginc |http://www.freecodecamp.com/sweetcodinginc
Sweet Coding :)
@SweetCodingInc
Jul 04 2017 16:41
@Pagnito :+1:
Zyberg
@Zyberg
Jul 04 2017 16:44
@phuzisham check it again as there might be one bracket too many ;) Here's what I meant for you to do:
function mutation(arr) {
  var word0 = arr[0].toLowerCase();
  var word1 = arr[1].toLowerCase();

  for (var i = 0; i < word0.length; i++) {
    if (word0.indexOf(word1[i]) === -1) {
      return false;
    }
  }
 return true;
}
Kelechi Chinaka
@kelechy
Jul 04 2017 16:46
how do i check if values in an array is empty or null
Pagnito
@Pagnito
Jul 04 2017 16:46
@SweetCodingInc hey can u tell me about next and done?
are those already built in methods?
Sweet Coding :)
@SweetCodingInc
Jul 04 2017 16:48
@Pagnito Are you using express?
Pagnito
@Pagnito
Jul 04 2017 16:48
@SweetCodingInc no
Sweet Coding :)
@SweetCodingInc
Jul 04 2017 16:49
nvm.. It is just a wrapper function to send control flow to next pipe
phuzisham
@phuzisham
Jul 04 2017 16:49
@Zyberg when I ran the code as above I failed two other tests. Here’s what I have right now (just moved ‘return true;’ inside for loop) and still passing all tests except the same one…
function mutation(arr) {
  var word0 = arr[0].toLowerCase();
  var word1 = arr[1].toLowerCase();

  for (var i = 0; i < word0.length; i++) {
    if (word0.indexOf(word1[i]) === -1) {
      return false;
    } 
    return true;
  }
}

mutation(["hello", "hey"]);
Pagnito
@Pagnito
Jul 04 2017 16:49
by pipe, is that like the next buffer?
Sweet Coding :)
@SweetCodingInc
Jul 04 2017 16:50
yes, in this case, pipe
Pagnito
@Pagnito
Jul 04 2017 16:51
so whats the difference between pipe and buffer, as i know buffer is like the holder of chunks of data, but i dont know what pipe is exactly
h1tag
@h1tag
Jul 04 2017 16:51
@phuzisham you are iterating through word1, but using word0's length
Sweet Coding :)
@SweetCodingInc
Jul 04 2017 16:51
Nope.. Those are comletely different things
@Pagnito
Pagnito
@Pagnito
Jul 04 2017 16:53
so does pipe creata stream?
phuzisham
@phuzisham
Jul 04 2017 16:54
Thanks for pointing that out @h1tag that didn’t make sense. Still getting same result though.
CamperBot
@camperbot
Jul 04 2017 16:54
phuzisham sends brownie points to @h1tag :sparkles: :thumbsup: :sparkles:
:cookie: 893 | @h1tag |http://www.freecodecamp.com/h1tag
h1tag
@h1tag
Jul 04 2017 16:55
@phuzisham and yeah, you're returning early
Pagnito
@Pagnito
Jul 04 2017 16:56
oh nvm i think i get it
phuzisham
@phuzisham
Jul 04 2017 16:56
Ok fixing the length and retun location fixed it. Thanks again @h1tag @Zyberg
CamperBot
@camperbot
Jul 04 2017 16:56
phuzisham sends brownie points to @h1tag and @zyberg :sparkles: :thumbsup: :sparkles:
:cookie: 269 | @zyberg |http://www.freecodecamp.com/zyberg
:warning: phuzisham already gave h1tag points
h1tag
@h1tag
Jul 04 2017 16:57
@phuzisham this is a good tool: http://pythontutor.com/
for challenges like this one
KinderPreet Singh
@kindercappy
Jul 04 2017 16:59
HELPPPPP
I started an infinite loop in one of my challenge. Its crashing the browser. I have use the //noprotect comment. Even if i close and reopen the challenge its still running the loop without me hitting the ctrl+enter. If i open someother challenge the site is working fine
i have not used //no protect*
h1tag
@h1tag
Jul 04 2017 17:00
KinderPreet Singh
@kindercappy
Jul 04 2017 17:04
@h1tag thanks :)
CamperBot
@camperbot
Jul 04 2017 17:04
kindercappy sends brownie points to @h1tag :sparkles: :thumbsup: :sparkles:
:cookie: 894 | @h1tag |http://www.freecodecamp.com/h1tag
Mike
@MikeJSchorah
Jul 04 2017 17:10
Is back-end web development easier than front-end web development?
teevik
@teevik
Jul 04 2017 17:15
Not in my opinion
Mike
@MikeJSchorah
Jul 04 2017 17:15
Ok. I WILL say that I think that the easiest part of web development to learn that I've seen so far is HTML and CSS. JavaScript front-end and JavaScript algorithms seems like rocket science. But, I'm surprised to find that NodeJS seems as easy as the front-end (after the database is configured).
Pagnito
@Pagnito
Jul 04 2017 17:21
@SweetCodingInc hey can u asnwer one more question?
Sweet Coding :)
@SweetCodingInc
Jul 04 2017 17:22
Shoot
h1tag
@h1tag
Jul 04 2017 17:25
@MikeJSchorah I think I find back-end harder, because it requires a more advanced and indepth js knowledge, and the many technologies you have to learn and make them work together. But still I find CSS challenging too, but not as back-end
Pagnito
@Pagnito
Jul 04 2017 17:27
@SweetCodingInc im a bit a confused about this.push()
u said this is holding buffer?
Sweet Coding :)
@SweetCodingInc
Jul 04 2017 17:28
I said this is instance of through
it could be an array or just an object
Pagnito
@Pagnito
Jul 04 2017 17:28
hmm
Sweet Coding :)
@SweetCodingInc
Jul 04 2017 17:28
:point_up: Here
Pagnito
@Pagnito
Jul 04 2017 17:28
so is the push() a regular js method here?
Sweet Coding :)
@SweetCodingInc
Jul 04 2017 17:28
could be, not sure
check Array.isArray(this)
if it gives you true, then that's regular Array.protoype.push
Valentin
@valentinlybmin
Jul 04 2017 17:29

Hey guys, quick question -

I made a function inside of a short for loop in one of the algorithm task and I got a warning sign that says "dont make functions inside of a short for loop". My algorithm was correct and I passed the task, but I was wondering why I got such a warning

Sweet Coding :)
@SweetCodingInc
Jul 04 2017 17:29
else its custom implemented by through
Pagnito
@Pagnito
Jul 04 2017 17:30
k hold on
it gave me false
Bryan Reese
@breese8009
Jul 04 2017 17:31
@valentinlybmin I think its just bad practice
Valentin
@valentinlybmin
Jul 04 2017 17:32
@breese8009 but why?
Bryan Reese
@breese8009
Jul 04 2017 17:34
@valentinlybmin cause ur iterating alot and it makes ur program heavy
when u have just a small data set nbd
Eric Hasegawa
@EricHasegawa
Jul 04 2017 17:34
I'm on the "Caesars Cipher" challenge in the basic algorithm section, is it supposed to be very difficult?
Bryan Reese
@breese8009
Jul 04 2017 17:34
but when u get into larger data sets, that can really slow ur program down
@EricHasegawa difficult for a beginner for sure
but if u got experience and know JS well then it prolly wont be that hard
Valentin
@valentinlybmin
Jul 04 2017 17:35
@breese8009 Right, makes sense. But to get this right, when its just a few iterations shouldnt be that bad , or?
Eric Hasegawa
@EricHasegawa
Jul 04 2017 17:36

function rot13(str) { // LBH QVQ VG!

  var newThing = "";

  var splitStr = str.split("");


  for (var i = 0; i < str.length; i++) {
   return str.charCodeAt(i);
  }





}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Could you tell me why my for loop returns only "83" and not every value?
Joseph
@revisualize
Jul 04 2017 17:36
@EricHasegawa Do you have an ASCII chart?
Eric Hasegawa
@EricHasegawa
Jul 04 2017 17:36
@revisualize Yeah, I'm just a little overwhelmed
Bryan Reese
@breese8009
Jul 04 2017 17:36
@EricHasegawa cause ur returning inside the for loop
Joseph
@revisualize
Jul 04 2017 17:36

@EricHasegawa

  for (var i = 0; i < str.length; i++) {
   return str.charCodeAt(i);
  }

this doesn't loop

Eric Hasegawa
@EricHasegawa
Jul 04 2017 17:37
@breese8009 @revisualize Right I should have known, how could I make it loop?
Joseph
@revisualize
Jul 04 2017 17:37
@EricHasegawa The return statement ends function execution and specifies a value to be returned to the function caller.
Syntax
return [[expression]];
expression
The expression to return. If omitted, undefined is returned instead.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/return
@EricHasegawa Store the value of str.charCodeAt(i); somewhere else
Paul
@candlefish
Jul 04 2017 17:38
@valentinlybmin Move the function outside of the loop and call it from within the loop. That way you aren't constantly re-creating the function on every iteration.
Bryan Reese
@breese8009
Jul 04 2017 17:38
@valentinlybmin i wouldnt do it, justo get good habits
Joseph
@revisualize
Jul 04 2017 17:38
@EricHasegawa Do you have an ASCII chart?
Valentin
@valentinlybmin
Jul 04 2017 17:38
@candlefish Will do , thanks. @breese8009 You are right, I will get back and fix it
CamperBot
@camperbot
Jul 04 2017 17:38
valentinlybmin sends brownie points to @candlefish and @breese8009 :sparkles: :thumbsup: :sparkles:
:cookie: 270 | @candlefish |http://www.freecodecamp.com/candlefish
:cookie: 755 | @breese8009 |http://www.freecodecamp.com/breese8009
Bryan Reese
@breese8009
Jul 04 2017 17:38
@valentinlybmin yea, @candlefish makes a great point
great*
Joseph
@revisualize
Jul 04 2017 17:39
@EricHasegawa You'll eventually need to reference an ASCII chart
Eric Hasegawa
@EricHasegawa
Jul 04 2017 17:39
@revisualize Yeah I have one open in my browser
Joseph
@revisualize
Jul 04 2017 17:39
Cool
Eric Hasegawa
@EricHasegawa
Jul 04 2017 17:39
function rot13(str) { // LBH QVQ VG!

  var newThing = "";

  var splitStr = str.split("");


  for (var i = 0; i < str.length; i++) {
   newThing = str.charCodeAt(i);
  }



  return newThing;

}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
How come this returns only "67" now?
Eric Hasegawa
@EricHasegawa
Jul 04 2017 17:40
@revisualize
Joseph
@revisualize
Jul 04 2017 17:40
@EricHasegawa newThing = str.charCodeAt(i); Overwrites on each loop
Eric Hasegawa
@EricHasegawa
Jul 04 2017 17:40
@revisualize I'm not sure how to store all the values without overwriting previous ones then
Joseph
@revisualize
Jul 04 2017 17:40
@EricHasegawa += or .push()
Bryan Reese
@breese8009
Jul 04 2017 17:41
@EricHasegawa u dont want a string of numbers... so i would use .push()
Valentin
@valentinlybmin
Jul 04 2017 17:41
@h1tag Thats very useful, thanks
CamperBot
@camperbot
Jul 04 2017 17:41
valentinlybmin sends brownie points to @h1tag :sparkles: :thumbsup: :sparkles:
:cookie: 895 | @h1tag |http://www.freecodecamp.com/h1tag
Bryan Reese
@breese8009
Jul 04 2017 17:41
array of numbers will be much easier to deal w
Joseph
@revisualize
Jul 04 2017 17:42
@breese8009 getting a string of numbers at least helps for making the if/else block later
Devansh Trivedi
@D3V4N5H
Jul 04 2017 17:42
I'm doing this wikipedia project. Issues with the API. Here:
https://codepen.io/_d3v4n5h/pen/mwrpGR
Bryan Reese
@breese8009
Jul 04 2017 17:42
lol id still rather deal w an array of nums
Joseph
@revisualize
Jul 04 2017 17:43
sure
Bryan Reese
@breese8009
Jul 04 2017 17:43
personal pref
Joseph
@revisualize
Jul 04 2017 17:43
easier at first
Eric Hasegawa
@EricHasegawa
Jul 04 2017 17:43
@breese8009 Yeah I understand how to use += to add them all, but how would I use .push()? Like syntax wise
Joseph
@revisualize
Jul 04 2017 17:44
@EricHasegawa make an array
Bryan Reese
@breese8009
Jul 04 2017 17:45
@EricHasegawa just create an empty array and do this to push ur results to empty array, arr.push(str.charCodeAt(i))
Joseph
@revisualize
Jul 04 2017 17:45
@EricHasegawa var decoded = [];
Bryan Reese
@breese8009
Jul 04 2017 17:45
^
Eric Hasegawa
@EricHasegawa
Jul 04 2017 17:47
@revisualize @breese8009 Okay got it, the next hint says to convert the ASCII back to english but what's the point of that?
revisualize @revisualize goes AFK.. Pain Meds.
Joseph
@revisualize
Jul 04 2017 17:47
@EricHasegawa before the .push()
if / else block
@EricHasegawa Side example If I have the number 72 How do I make that an ASCII letter?
first rotate tho
:)
Eric Hasegawa
@EricHasegawa
Jul 04 2017 17:49
@revisualize str.fromCharCode(72) ?
Joseph
@revisualize
Jul 04 2017 17:49
@EricHasegawa Ok
Eric Hasegawa
@EricHasegawa
Jul 04 2017 17:49
@breese8009 That's the part I'm not sure how to do
@revisualize Is that right?
Joseph
@revisualize
Jul 04 2017 17:50
IDK
I'm trying to take pain meds for my broken hand
Eric Hasegawa
@EricHasegawa
Jul 04 2017 17:50
@revisualize Hahah okay sorry
jasonrest
@jasonrest
Jul 04 2017 17:51
Hey everyone.
The degree symbol is not showing for farenheit after clicking my convert button. but when I try to add + "&deg" to the end of
var fahrenheit = Math.round(9/5 * (data.main.temp-273) + 32);
I get a NaN as a result. Any ideas on what's causing that?
https://codepen.io/jasonrest/pen/mwXZNY/
Bryan Reese
@breese8009
Jul 04 2017 17:51
@EricHasegawa u want to rotate String.fromCharCode(i+13)
thats not the answer
but thats how u would rotate
and figuring out how ur gotta rotate between 65-90
gonna*
u dont wanna go beyond 90 or below 65
Munkhmanlai
@munkhmanlai
Jul 04 2017 17:53
taking numbers from the prompt and write.out to display only even numbers in order. Do you guys know how to do this?
v
taking numbers from the prompt and write.out to display only even numbers in order. Do you guys know how to do this?
taking numbers from the prompt and write.out to display only even numbers in order. Do you guys know how to do this?
Bryan Reese
@breese8009
Jul 04 2017 17:53
@munkhmanlai ewww promot
prompt
Eric Hasegawa
@EricHasegawa
Jul 04 2017 17:53
@breese8009 Okay I'll try to figure this out
Munkhmanlai
@munkhmanlai
Jul 04 2017 17:54
<!DOCTYPE html>
<html>
    <head>
        <title>Array1</title>
        <script type="text/javascript">

            var a = [];

            for(var i = 0; i < 10; i++) {
                a.push(prompt("Enter your number"));
            }

            for(i = 0; i < a.length; i++) {
                for(var j = i; j < a.length; j++) {
                    if(a[i] > a[j]) {
                        var t = a[i];
                        a[i] = a[j];
                        a[j] = t;
                    }
                }
            }

            for(i = 0; i < a.length; i++) {
                document.write("<h1>" + a[i] + "</h1>");
            }


        </script>
    </head>
    <body>

    </body>
</html>
idk the single thing that is going on here. Is there anyone who could explain it to me thank you
Bryan Reese
@breese8009
Jul 04 2017 17:55
@munkhmanlai no idea what ur trying to do here, u have 4 for loops