These are chat archives for FreeCodeCamp/HelpJavaScript

10th
Mar 2017
Ogundele Olumide
@Lumexralph
Mar 10 2017 00:00
:trumpet:
John Nunns
@johnnunns
Mar 10 2017 00:00
cool, almost there

function spinalCase(str) {
  // "It's such a fine line between stupid, and clever."
  // --David St. Hubbins

  var regex = /[_-]/g;
  return str.replace(regex, ' ').toLowerCase().split(' ').join('-');
}

spinalCase("The_Andy_Griffith_Show");
James McCabe
@mcca0447
Mar 10 2017 00:00
@moigithub thanks
CamperBot
@camperbot
Mar 10 2017 00:00
mcca0447 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 2827 | @moigithub |http://www.freecodecamp.com/moigithub
John Nunns
@johnnunns
Mar 10 2017 00:01
so this accounts for 2 of 4, but not the arguments that include a string like "AStringIsAString"
Gulsvi
@gulsvi
Mar 10 2017 00:01
I hated spinal case for that exact reason - thought it was going to be so easy at first
John Nunns
@johnnunns
Mar 10 2017 00:01
haha same.
Gulsvi
@gulsvi
Mar 10 2017 00:01
Then you think, okay, I'll just modify my regex to look for capital letters :p
not quite... lol
Adam
@GoingAllTheWayUp
Mar 10 2017 00:02
Anyone know about casting:mirroring android phone to windows 10 on same network?
John Nunns
@johnnunns
Mar 10 2017 00:02
well do I have to do a for loop which looks at if it's a capital letter && there's no space before it?
Pieter Stokkink
@forkerino
Mar 10 2017 00:03

@moigithub since you're using the spread operator already:

const uniteUnique = () => [...(new Set([].concat(...arguments)))];

:P

Moisés Man
@moigithub
Mar 10 2017 00:03
yep.. was gonna do that.. but too lazy :D
Pieter Stokkink
@forkerino
Mar 10 2017 00:03
haha
Moisés Man
@moigithub
Mar 10 2017 00:03
using arrow functions seems argumetns doesnt work
Gulsvi
@gulsvi
Mar 10 2017 00:04
@johnnunns There is an easy way to do it without a loop, but you'll have to study regex for a bit
HeebieGeeBee
@HeebieGeeBee
Mar 10 2017 00:04
@johnnunns regex is good for looking at strings
Pieter Stokkink
@forkerino
Mar 10 2017 00:04
@moigithub yeah, I get some errors, but it passes the tests.
hmmm
Manish Giri
@Manish-Giri
Mar 10 2017 00:05
@Lumexralph I :heart: barca
John Nunns
@johnnunns
Mar 10 2017 00:06
maybe I should do this
that**
Ogundele Olumide
@Lumexralph
Mar 10 2017 00:06
@Manish-Giri supporter of Man U but have soft spot for R.Madrid
John Nunns
@johnnunns
Mar 10 2017 00:06
i don't like where it's looking I'm heading right now :joy:
for(i=1;i<str.length;i++){
    if(str[i]===str[i].toUpperCase()&&(str[i].length-1)!== " "){
      ;
    }
Gulsvi
@gulsvi
Mar 10 2017 00:06
Take a look at "capturing groups" in regex :)
HeebieGeeBee
@HeebieGeeBee
Mar 10 2017 00:07
@johnnunns you could to it with loops but it will be messsy
John Nunns
@johnnunns
Mar 10 2017 00:07
actually I wrote that wrong anyways I needed to use an indexOf method
ok, let me just try and figure it out the better way
Pieter Stokkink
@forkerino
Mar 10 2017 00:12

@moigithub so this would be error proof:

const uniteUnique = (...a) => [...(new Set([].concat(...a)))];

definitely not the most readable.

everything is spread.
:P
Moisés Man
@moigithub
Mar 10 2017 00:13
:D
John Nunns
@johnnunns
Mar 10 2017 00:14
man I'm at the end of my coding day and I'm trying to learn this freaking regexp :joy:
things aren't going well
Moisés Man
@moigithub
Mar 10 2017 00:14
www.regexone.com <-- tutorial
John Nunns
@johnnunns
Mar 10 2017 00:15
thanks @moigithub
CamperBot
@camperbot
Mar 10 2017 00:15
johnnunns sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 2828 | @moigithub |http://www.freecodecamp.com/moigithub
Pieter Stokkink
@forkerino
Mar 10 2017 00:16
Bedtime!
forkerino @forkerino :zzz:
Ogundele Olumide
@Lumexralph
Mar 10 2017 00:16
@forkerino almost there.....
Jason Luboff
@JLuboff
Mar 10 2017 00:16
Adios
HeebieGeeBee
@HeebieGeeBee
Mar 10 2017 00:16
@forkerino night
Manish Giri
@Manish-Giri
Mar 10 2017 00:17
@forkerino :wave:
Ogundele Olumide
@Lumexralph
Mar 10 2017 00:17
@forkerino Gute Nacht
James McCabe
@mcca0447
Mar 10 2017 00:23
If an array, arr has already been passed into a function to be chunked, why would it be important to use the statement arr=arr.slice(); Isn't that redundant??
HeebieGeeBee
@HeebieGeeBee
Mar 10 2017 00:24
@mcca0447 why would you be doing that?
Darthjarjardotcom
@Darthjarjardotcom
Mar 10 2017 00:25
Increment a Number with JavaScript
i am stuck on that pls help
James McCabe
@mcca0447
Mar 10 2017 00:26
@HeebieGeeBee , I'm reviewing an intermediate solution for a problem and it uses that line. The line seemed unneccessary, I just wanted to bounce it off of someone else to see if there was any logic behind it.
Manish Giri
@Manish-Giri
Mar 10 2017 00:26
@Darthjarjardotcom what's the problem?
Jason Luboff
@JLuboff
Mar 10 2017 00:27
@Darthjarjardotcom To use the ++ incrementor, you apply it directly to the variable name myPotatoe++
HeebieGeeBee
@HeebieGeeBee
Mar 10 2017 00:27
@mcca0447 got a link?
Darthjarjardotcom
@Darthjarjardotcom
Mar 10 2017 00:27
ok ill give it a try

var myVar = 87;

// Only change code below this line
myVar = myVar++;

Jason Luboff
@JLuboff
Mar 10 2017 00:29
@Darthjarjardotcom No need for myVar =
Darthjarjardotcom
@Darthjarjardotcom
Mar 10 2017 00:29
OHHH
thx\
James McCabe
@mcca0447
Mar 10 2017 00:30
drinkwaterman
@drinkwaterman
Mar 10 2017 00:30
what about myvar += 1, is it the same as myvarr++?
HeebieGeeBee
@HeebieGeeBee
Mar 10 2017 00:30
@mcca0447 no worries i was reading it, yeah i dunno why they would do that
the0ffh
@the0ffh
Mar 10 2017 00:31
hey guys,
do you know by chance if it is possible to play with recursion on FCC?
Jason Luboff
@JLuboff
Mar 10 2017 00:31
@the0ffh Yes
@drinkwaterman Yes
James McCabe
@mcca0447
Mar 10 2017 00:31
@drinkwaterman Its pretty much the same thing, later on you just get in the habit of reading myVar++ as "increment by one" makes code easier to read
Jason Luboff
@JLuboff
Mar 10 2017 00:31
@drinkwaterman But you could do myVar += any number whereas ++ is strictly adding 1
the0ffh
@the0ffh
Mar 10 2017 00:32
Thx. I will fight with it more then ;)
drinkwaterman
@drinkwaterman
Mar 10 2017 00:32
Thank you @JLuboff @mcca0447 +5
CamperBot
@camperbot
Mar 10 2017 00:32
drinkwaterman sends brownie points to @jluboff and @mcca0447 :sparkles: :thumbsup: :sparkles:
:cookie: 246 | @mcca0447 |http://www.freecodecamp.com/mcca0447
:star2: 1090 | @jluboff |http://www.freecodecamp.com/jluboff
James McCabe
@mcca0447
Mar 10 2017 00:32
@HeebieJeeBee Right on, I guess I'll leave it out.
thanks @HeebieGeeBee
CamperBot
@camperbot
Mar 10 2017 00:33
mcca0447 sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1013 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
Joanna Barajas
@chefjoannacodes
Mar 10 2017 00:35
is this the correct camelCase? var studlyCapVaR;
HeebieGeeBee
@HeebieGeeBee
Mar 10 2017 00:36
looks like it
Jason Luboff
@JLuboff
Mar 10 2017 00:36
@chefjoannacodes No
var studlyCapVar
Joanna Barajas
@chefjoannacodes
Mar 10 2017 00:36
oh yea thanks!!
HeebieGeeBee
@HeebieGeeBee
Mar 10 2017 00:37
oh yeah the r
derp
Jason Luboff
@JLuboff
Mar 10 2017 00:37
@HeebieGeeBee :trollface:
HeebieGeeBee
@HeebieGeeBee
Mar 10 2017 00:38
now, what is a studly cap var ?
Jason Luboff
@JLuboff
Mar 10 2017 00:39
Good question. No answer
Avery Biskup
@fraknard
Mar 10 2017 00:41
http://codepen.io/fraknard/pen/evBQQK?editors=1111 How do I post the twitter message without it being broken because of special characters?
HeebieGeeBee
@HeebieGeeBee
Mar 10 2017 00:42
@fraknard could try to make a regex to remove them
Avery Biskup
@fraknard
Mar 10 2017 00:44
What's regex?
HeebieGeeBee
@HeebieGeeBee
Mar 10 2017 00:44
regular expression
Avery Biskup
@fraknard
Mar 10 2017 00:44
Oh, yes, but I'd like to keep them in.
the0ffh
@the0ffh
Mar 10 2017 00:44
@fraknard Regular Expression. Check the previous tasks - it's nicely explained.
Adam VanZuiden
@adamvz
Mar 10 2017 00:45
@fraknard regular expression /\S\g ect
Avery Biskup
@fraknard
Mar 10 2017 00:45
Using .replace?
HeebieGeeBee
@HeebieGeeBee
Mar 10 2017 00:45
@fraknard but you dont need them for your twitter link
Oleh
@Lufter
Mar 10 2017 00:45
Greetings guys,
Could you please point me what i missed in my code .
Task - Counting Cards.
The only sub-task left is "Cards Sequence 2, 2, 10 should return "1 Bet"
It is returning "1 Bet" but not accepting the answer...
My Code:

var count = 0;
var bet = "Bet";
var hold = "Hold";
function cc(card) {
  // Only change code below this line
    switch (card){
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      {
      count = count + 1;
    }
      return count + " " + bet;
    case 7:
    case 8:
    case 9:
      {
        if (count > 0){
          return count + " " + bet; 
        }
        else if (count <= 0){
          return count + " " + hold;
        }
    }
      break;
    case 10:
    case 'J':
    case 'Q':
    case 'K':
    case 'A':
      {
      count = count - 1;
    }
      return count + " " + hold;  
  }
  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(2); cc(10); cc('K'); cc('A');
HeebieGeeBee
@HeebieGeeBee
Mar 10 2017 00:46
so you can use a variable that has them replaced for the link , and normal for the webpage
Avery Biskup
@fraknard
Mar 10 2017 00:46
Do I have to use replace?
HeebieGeeBee
@HeebieGeeBee
Mar 10 2017 00:46
@fraknard
Avery Biskup
@fraknard
Mar 10 2017 00:46
I thought they were the same?
HeebieGeeBee
@HeebieGeeBee
Mar 10 2017 00:46
thats probably a good method yes
what do you mean the same?
the0ffh
@the0ffh
Mar 10 2017 00:47
@Lufter add .trim();
HeebieGeeBee
@HeebieGeeBee
Mar 10 2017 00:48
@Lufter dont do the returns in the switch statement
the0ffh
@the0ffh
Mar 10 2017 00:48
@Lufter oh wait.. sorry..
jmarcano17
@jmarcano17
Mar 10 2017 00:48
i have no idea what they want me to do here

Word Blanks
We will now use our knowledge of strings to build a "Mad Libs" style word game we're calling "Word Blanks". You will create an (optionally humorous) "Fill in the Blanks" style sentence.

You will need to use string operators to build a new string, result, using the provided variables: myNoun, myAdjective, myVerb, and myAdverb.

You will also need to use additional strings, which will not change, and must be in between all of the provided words. The output should be a complete sentence.

We have provided a framework for testing your results with different words. The tests will run your function with several different inputs to make sure all of the provided words appear in the output, as well as your extra strings.

Adam VanZuiden
@adamvz
Mar 10 2017 00:48
@Lufter you should be testing the count after the switch statement.
Oleh
@Lufter
Mar 10 2017 00:49
@adamvz let me try .. :)
Adam VanZuiden
@adamvz
Mar 10 2017 00:49
@jmarcano17 the excercise will give you a list of arguments. You job will be to take those arguments and concatenate them some other words to make a new sentence
Avery Biskup
@fraknard
Mar 10 2017 00:49
@HeebieGeeBee Isn't the string that you give the href callback what shows up in the text box?
quoteText.replace(/'/i, ""); Does work..
jmarcano17
@jmarcano17
Mar 10 2017 00:50
is it normal for me to learn html/css like ive known it my whole but when it comes to javascript im clueless?
whole life*
HeebieGeeBee
@HeebieGeeBee
Mar 10 2017 00:50
quoteText.replace(/'/i, "") this doesnt change the orgional string it returns a new strink with elements replaced
Adam VanZuiden
@adamvz
Mar 10 2017 00:50
@jmarcano17 so it will give you the following arguments myNoun, myAdjective, myVerb, myAdverb
Oleh
@Lufter
Mar 10 2017 00:51
Thank you @HeebieGeeBee @adamvz
CamperBot
@camperbot
Mar 10 2017 00:51
lufter sends brownie points to @heebiegeebee and @adamvz :sparkles: :thumbsup: :sparkles:
:cookie: 280 | @adamvz |http://www.freecodecamp.com/adamvz
:star2: 1014 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
jmarcano17
@jmarcano17
Mar 10 2017 00:51
this is the code they start me out with

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line

// Your code above this line
return result;
}

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

Avery Biskup
@fraknard
Mar 10 2017 00:51
Oh, I didn't add the quoteText =
But, it still doesn't work.
Oleh
@Lufter
Mar 10 2017 00:51
It was not logical to put "if" statement inside the switch-case
=)
Adam VanZuiden
@adamvz
Mar 10 2017 00:51
@jmarcano17 so you will need to concatenate the strings they give as arguments and then add them to some other words to make a real setence.
HeebieGeeBee
@HeebieGeeBee
Mar 10 2017 00:51
@fraknard what are you doing with that regex?
Avery Biskup
@fraknard
Mar 10 2017 00:52
quoteText = quoteText.replace(/;/i, "");
quoteText = quoteText.replace(/"\'"/i, "");
I need to remove these.
HeebieGeeBee
@HeebieGeeBee
Mar 10 2017 00:52
@fraknard ?
why?
Avery Biskup
@fraknard
Mar 10 2017 00:53
hmm?
Why what?
jmarcano17
@jmarcano17
Mar 10 2017 00:53
would it be something like wordBlanks =("dog", "big", "ran","quickly") + (other words) ?
Adam VanZuiden
@adamvz
Mar 10 2017 00:53
@jmarcano17 so for the first test case they give ["dog","big","ran,"quickly"] Now in your function you are given the following arguments wordBlanks(myNoun,myAdjective,myVerb,myAdverb)
HeebieGeeBee
@HeebieGeeBee
Mar 10 2017 00:54
@fraknard why do you need to remoe semi colons and quote marks?
there arent any in the text
Avery Biskup
@fraknard
Mar 10 2017 00:54
Because they don't transfer in the link.
Adam VanZuiden
@adamvz
Mar 10 2017 00:54
@jmarcano17 so your job is to take those arguments and add them together to make a real sentence. Maybe something using the first example like "The big dog ran quickly".
Avery Biskup
@fraknard
Mar 10 2017 00:54
in the quoteText.
Try using it with twitter.
The text in the twitter box stops when it reaches a ' or ; or -
Adam VanZuiden
@adamvz
Mar 10 2017 00:55
@jmarcano17 but the function should be able to work no matter what words are passed as arguments. So don't reassign them.
Avery Biskup
@fraknard
Mar 10 2017 00:55
or "
Joseph
@revisualize
Mar 10 2017 00:55

@adamvz Gist by revisualize / FreeCodeCamp - Word_Blanks.js
The function declaration was set up as... function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) giving the function name as wordBlanks and with four parameter of myNoun, myAdjective, myVerb and myAdverb.
There is more that I could go into (if you want I can) but, I'll sum it up with:
Parameters are treated like variables that represent the values that get passed into your function from the function call (arguments).
Here's an example of this:

function hello(fName, uName) {
     return "Hello " + fName + " " + uName + ", How is your day?";
}
hello("Joseph", "@revisualize"); // "Hello Joseph @revisualize, How is your day?"
hello("Bella", "@bellaknoti"); // "Hello Bella @bellaknoti, How is your day?"
hello("Andy", "@dirn"); // "Hello Andy @dirn, How is your day?"

You can use the fName and uName parameters just like a variable inside of your function.

Adam VanZuiden
@adamvz
Mar 10 2017 00:55
@revisualize I should just copy and paste that somewhere.
jmarcano17
@jmarcano17
Mar 10 2017 00:55
so i would just string together the words to make a sentence?
HeebieGeeBee
@HeebieGeeBee
Mar 10 2017 00:56
@fraknard there shouldnt be any in the quote text
Avery Biskup
@fraknard
Mar 10 2017 00:56
Click generate a few times.
HeebieGeeBee
@HeebieGeeBee
Mar 10 2017 00:56
its the html tags you want to remove @fraknard
Avery Biskup
@fraknard
Mar 10 2017 00:56
@HeebieGeeBee
Yeah, those too.
Thanks @HeebieGeeBee, I have to go, I will figure it out later.
CamperBot
@camperbot
Mar 10 2017 00:58
fraknard sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1015 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
Adam VanZuiden
@adamvz
Mar 10 2017 00:58
@jmarcano17 read Joseph's post
Darthjarjardotcom
@Darthjarjardotcom
Mar 10 2017 00:59
in the Convert Celsius to Fahrenheit challenge,

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line
fahrenheit = 9/5 + 32;

// Only change code above this line
return fahrenheit;
}

// Change the inputs below to test your code
convertToF(-30);
how is this code wrong

jmarcano17
@jmarcano17
Mar 10 2017 01:00
i understand now. Thanks guys @revisualize @adamvz
CamperBot
@camperbot
Mar 10 2017 01:00
jmarcano17 sends brownie points to @revisualize and @adamvz :sparkles: :thumbsup: :sparkles:
:cookie: 281 | @adamvz |http://www.freecodecamp.com/adamvz
:star2: 3470 | @revisualize |http://www.freecodecamp.com/revisualize
Adam VanZuiden
@adamvz
Mar 10 2017 01:01
@Darthjarjardotcom you are declaring fahrenheit but you are not assigning it any value.
Joseph
@revisualize
Mar 10 2017 01:01

@Darthjarjardotcom
There is the function declaration of function convertToF(celsius) { .. You have a function name of convertToF and a parameter of celsius
Parameters are used just like variables. So, inside of the function you can use celsius JUST like any other variable.
If I have this code:

function addThree (num) {
    var result;
    result = num + 3;
    return result;
}

So, when we make the function call of:

addThree(10);

You're calling the function addThree You're also passing a value 10 as an argument.
In the function declaration of function addThree (num) { You see that there is a parameter defined of num
When we do addThree(10) then the value of the parameter num is passed the argument value of ... 10
Then if you follow the code through.. result = num + 3; ... and we know the value of num is 10.
Therefore, if we follow through the function we end up with ... result = 10 + 3; then result = 13; then we return the result.

You can apply those concepts to the function convertToF(celsius) { }

Adam VanZuiden
@adamvz
Mar 10 2017 01:02
@revisualize do you have one of those for every challenge?
Adam
@GoingAllTheWayUp
Mar 10 2017 01:02
@Darthjarjardotcom the equation requires a variable
Joseph
@revisualize
Mar 10 2017 01:02
@adamvz Not every one.
Adam
@GoingAllTheWayUp
Mar 10 2017 01:02
@Darthjarjardotcom 9/5 + 32 is not the equation
Adam VanZuiden
@adamvz
Mar 10 2017 01:03
@revisualize just the ones that get asked every hour in here? :-P
Yonatan Rojas
@MajorTom250993
Mar 10 2017 01:05
Dear coders, I need your help. I’m trying to accept a 10 digit number from a user using execption in JS. But when I run the code it dosn’t display the number. Here’s my code:
function tenDigitNumber(number) {
  try {
    if (number.length != 10) {
      throw(" " + "We need a ten digit number");
    } else {
      console.log(number);
    }
  } catch (e) {
    console.log("Error," + e);
  } finally {
    console.log("Holi Guaquimoli");
  }
}

console.log(tenDigitNumber(1234567890));
Adam
@GoingAllTheWayUp
Mar 10 2017 01:05
@MajorTom250993 whats 'catch' mean?
whats 'try'
Raja Sharma
@Raja-Sharma
Mar 10 2017 01:06
Error catching
Prevents one error from spiraling to more problems
Adam
@GoingAllTheWayUp
Mar 10 2017 01:07
Oh ok im lost
dahn88
@dahn88
Mar 10 2017 01:07
lol
Darthjarjardotcom
@Darthjarjardotcom
Mar 10 2017 01:08
so my code would look something like this:

function convertToF(9/5 + 32) {
var fahrenheit;
// Only change code below this line
fahrenheit = celsius;

// Only change code above this line
return fahrenheit;
}

// Change the inputs below to test your code
convertToF(30);

Adam
@GoingAllTheWayUp
Mar 10 2017 01:08
@Darthjarjardotcom no 9/5 + 32 is not the equation at all
Moisés Man
@moigithub
Mar 10 2017 01:09
check the comments.. the one which start with //
@Darthjarjardotcom
Adam
@GoingAllTheWayUp
Mar 10 2017 01:09
its celsius times 9 divided by 5 plus 35
Adam VanZuiden
@adamvz
Mar 10 2017 01:10
@Darthjarjardotcom you are regressing a little bit here. Your first code you posted was pretty good and only needed one or two changes.
here's your original
function convertToF(celsius) {
var fahrenheit;
// Only change code below this line
fahrenheit = 9/5 + 32;

// Only change code above this line
return fahrenheit;
}

// Change the inputs below to test your code
convertToF(-30);
dahn88
@dahn88
Mar 10 2017 01:11
does anyone know a good guide/lesson on nested for loops?
Adam VanZuiden
@adamvz
Mar 10 2017 01:11
@Darthjarjardotcom the reason it doesn't work is because you are declaring var fahrenheit and not assinging it any value.
so when you try to run your equation on it it has no result because it doesn't know what it's supposed to doing it to.
Darthjarjardotcom
@Darthjarjardotcom
Mar 10 2017 01:12
yes i am returning to that original code and modifing it
Adam
@GoingAllTheWayUp
Mar 10 2017 01:13
celsius * (9 / 5) + 32, this is the wheel that was invented for you in this problem
Darthjarjardotcom
@Darthjarjardotcom
Mar 10 2017 01:13
im taking a break to think about things
Adam VanZuiden
@adamvz
Mar 10 2017 01:14
@Darthjarjardotcom so looking at the code I posted. convertToF(celsius) celsius is what is called an argument. It can be used inside the of the function like variable. It will be equal to what you call the function with. IN this case it's called with -30 with convertToF(-30) at the bottom of the file. So inside of your function celsius is equal to -30
Adam
@GoingAllTheWayUp
Mar 10 2017 01:14
Just need to assign this equation to a variable, within the function that has celsius as parameter. @Darthjarjardotcom
Darthjarjardotcom
@Darthjarjardotcom
Mar 10 2017 01:15
i know what i did wrong i din't say that fahrenheit euqalled whatever the numbers where suppose to equal,
do you guys reccomend me taking a couple steps backward for a better understanding?
Adam
@GoingAllTheWayUp
Mar 10 2017 01:16
you had it correct the first time, your equation was wrong
Adam VanZuiden
@adamvz
Mar 10 2017 01:16
@Darthjarjardotcom maybe. You should focus on the variables and arguments. You can fix your code in 2 easy fixes. You are very close.
Darthjarjardotcom
@Darthjarjardotcom
Mar 10 2017 01:17
thanks. i figured it out. i gtg
Adam
@GoingAllTheWayUp
Mar 10 2017 01:17
ok
you can lead them to water bro
Darthjarjardotcom
@Darthjarjardotcom
Mar 10 2017 01:19
?
Adam
@GoingAllTheWayUp
Mar 10 2017 01:20
how did you do it? we all know the solution
Darthjarjardotcom
@Darthjarjardotcom
Mar 10 2017 01:21
i forgot to add the multiplication part
Adam
@GoingAllTheWayUp
Mar 10 2017 01:23
I'm sorry I just assumed you knew what I was saying when i said equation
I should have explained it
Johnny
@JohnnyBizzel
Mar 10 2017 01:51
@dahn88 use a nested loop on a 2-dimentional array
Victoria Zambrano
@vzambrano98
Mar 10 2017 01:55
anyone elsehaving issues with this ---->
"getCurrentPosition() and watchPosition() no longer work on insecure origins. To use this feature, you should consider switching your application to a secure origin, such as HTTPS. See https://goo.gl/rStTGz for more details."
Margaret
@Margaret2
Mar 10 2017 01:55
@vzambrano98 gotta use https for navigator.geolocation stuff
Adam VanZuiden
@adamvz
Mar 10 2017 01:55
@vzambrano98 Yes it took me a couple days to figure. You will need to make sure you are connected to codepen.io through a https:// connections
Margaret
@Margaret2
Mar 10 2017 01:55
alternative is http://ip-api.com/json @vzambrano98
Adam
@GoingAllTheWayUp
Mar 10 2017 01:55
@vzambrano98 navigator.geolocation did not work in FCC for me
Adam VanZuiden
@adamvz
Mar 10 2017 01:56
@vzambrano98 the easiest way around it is to type https:// before codepen.io
Adam
@GoingAllTheWayUp
Mar 10 2017 01:57
I had to use a thirdparty API to get the long/lat
Victoria Zambrano
@vzambrano98
Mar 10 2017 01:58
oooh @Margaret2 I like that. but also, i feel like such a noob, for showing that i didn't just type that in lol!!!
thanks guys @adamvz
CamperBot
@camperbot
Mar 10 2017 01:58
vzambrano98 sends brownie points to @margaret2 and @adamvz :sparkles: :thumbsup: :sparkles:
:cookie: 282 | @adamvz |http://www.freecodecamp.com/adamvz
:star2: 1950 | @margaret2 |http://www.freecodecamp.com/margaret2
Adam
@GoingAllTheWayUp
Mar 10 2017 01:58
@adamvz I found https:// also caused me to get confused when my other pens stoped working becuase the don't require https://
Adam VanZuiden
@adamvz
Mar 10 2017 01:58
@GoingAllTheWayUp you can make it work but in chrome getCurrentPosition requires an https:// connection. Of course I ran into problems with OpenWeatherMap because it wouldn't let me call the JSON through an https connection so the mismatch was being blocked.
Adam
@GoingAllTheWayUp
Mar 10 2017 01:59
yeah its just about getting a good grasp of outside factors, it was a good project
Adam VanZuiden
@adamvz
Mar 10 2017 01:59
@GoingAllTheWayUp so then I had to find another weather api after I had figured out how to use the OpenWeatherMap one. Spent way too much time on that project
I wish I had Margaret's link
Victoria Zambrano
@vzambrano98
Mar 10 2017 02:04
APIs for days!
Adam
@GoingAllTheWayUp
Mar 10 2017 02:08
@adamvz any big ideas on what your going to do with your all your ablities? good evil? lol
I like the startup / technology side
make universal web apps
Adam VanZuiden
@adamvz
Mar 10 2017 02:10
@GoingAllTheWayUp Honestly. I don't think I will ever get a job doing this.
Adam
@GoingAllTheWayUp
Mar 10 2017 02:10
Well im a DIYer
thats why I ask if your into ideas?
I ask becuase you knew alot before FCC, we can all see that
Adam VanZuiden
@adamvz
Mar 10 2017 02:12
Actually I had no idea.
Adam
@GoingAllTheWayUp
Mar 10 2017 02:12
nice, humble man
Adam VanZuiden
@adamvz
Mar 10 2017 02:12
no really. I started 2 weeks ago.
eyesore-
@eyesore-
Mar 10 2017 02:12
Yo.
Adam VanZuiden
@adamvz
Mar 10 2017 02:12
It just makes sense to me.
Adam
@GoingAllTheWayUp
Mar 10 2017 02:12
I see that, good job!
eyesore-
@eyesore-
Mar 10 2017 02:12
Anyone need help?
Adam
@GoingAllTheWayUp
Mar 10 2017 02:13
Yeah I told a women I loved her now she gone.
eyesore-
@eyesore-
Mar 10 2017 02:13
Damn, I'm sorry. I can't help there...
Unless it's a chatbot then maybe.
Might be in your localStorage
Adam VanZuiden
@adamvz
Mar 10 2017 02:14
Chatbot will love you forever.
@eyesore- I am getting a message that says my localStorage is corrupted. Can I still find her there?
eyesore-
@eyesore-
Mar 10 2017 02:15
@adamvz Did you transition from another language to JS or just starting JS from complete scratch?
王乃坤
@Cnwn
Mar 10 2017 02:15
avaSript Word Blanks in this topic how to write?
eyesore-
@eyesore-
Mar 10 2017 02:15
Dude, she's gone /: and ruined your storage.
@Cnwn What you got so far?
Adam
@GoingAllTheWayUp
Mar 10 2017 02:15
all i had was in localstorage and theres memory shortage
treeshadegit
@treeshadegit
Mar 10 2017 02:16
Just have to vent for a sec here. The html/css/bootstrap etc courses weren't bad at all, but these javascript lessons are kicking my ass
Adam VanZuiden
@adamvz
Mar 10 2017 02:16
@eyesore- just started from scratch. I think 3 years I did a couple of tutorials in python. In high school I learned QBasic....that was over 10 years ago though....
eyesore-
@eyesore-
Mar 10 2017 02:16
@treeshadegit if you get super stuck shoot me a message and I'll do my best to clear up any confusion.
Margaret
@Margaret2
Mar 10 2017 02:17
@Cnwn you have to add up the variables to make a sentence, so for example
"My " + myAdjective + " " + myNoun" which would result in something like "My big dog"
eyesore-
@eyesore-
Mar 10 2017 02:17
@adamvz Oh, that's pretty cool.
Adam VanZuiden
@adamvz
Mar 10 2017 02:17
So maybe it wasn't completely from scratch since I sort of understood the theory of programming a little.
treeshadegit
@treeshadegit
Mar 10 2017 02:17
@eyesore- Was javascript mind blowingly difficult at first? I didn't struggle much up until this point but these lessons are insane..
Adam
@GoingAllTheWayUp
Mar 10 2017 02:17
@treeshadegit where are you now?
eyesore-
@eyesore-
Mar 10 2017 02:18
@treeshadegit it can be depending on your background, but many times that you get stuck you may be overthinking it.
Adam
@GoingAllTheWayUp
Mar 10 2017 02:18
i see
treeshadegit
@treeshadegit
Mar 10 2017 02:18
@GoingAllTheWayUp not far at all.. "Passing Values to Functions with Arguments", like halfway through first list of javascript lessons
Adam VanZuiden
@adamvz
Mar 10 2017 02:18
@treeshadegit JS is different animal than HTML and CSS. It taxes a different part of your brain. HTML/CSS is markup
Adam
@GoingAllTheWayUp
Mar 10 2017 02:19
@treeshadegit keep it up, concepts like "if" and "for" how are you with them?
Adam VanZuiden
@adamvz
Mar 10 2017 02:19
Markup is just like it sounds, its putting words and pictures to the paper. With JS you are manipulating math functions to do your bidding. To me JS is much more logical than HTML/CSS.
treeshadegit
@treeshadegit
Mar 10 2017 02:19
@eyesore- @adamvz I have a tendency to overthink stuff, but at least with the markup languages I saw how it all worked together. I still have no how these JS lessons fit together
@GoingAllTheWayUp havn't even got that part yet.. lmao
were you guys having to google for help on many of the early lessons?
Adam
@GoingAllTheWayUp
Mar 10 2017 02:20
JavaScript is how you get the website to run a program ion the browser
Adam VanZuiden
@adamvz
Mar 10 2017 02:20
@treeshadegit don't give up! It will make sense shortly! You have to conceptalize your legs before you can walk. These are just laying the groundwork for you later.
Adam
@GoingAllTheWayUp
Mar 10 2017 02:21
Its just like qBasic and many other languages
may have come and many more will come
王乃坤
@Cnwn
Mar 10 2017 02:21
@Margaret2
Thank you very much.
CamperBot
@camperbot
Mar 10 2017 02:21
cnwn sends brownie points to @margaret2 :sparkles: :thumbsup: :sparkles:
:star2: 1952 | @margaret2 |http://www.freecodecamp.com/margaret2
Adam
@GoingAllTheWayUp
Mar 10 2017 02:21
but core concepts like an if statement are a good place to start
Adam VanZuiden
@adamvz
Mar 10 2017 02:22
@treeshadegit consider these lessons as reference. They build upon each other little by little. If you don't understand something look back to previous lessons and what you learned and think about how you can apply what you learned. Also read the example and text carefully for what is going on.
eyesore-
@eyesore-
Mar 10 2017 02:22
@treeshadegit if something throws you for a complete fucking loop I'd be down to break up step by step for you.
@treeshadegit Another good resource for starting out is http://eloquentjavascript.net/
Adel
@AdelMahjoub
Mar 10 2017 02:24
while the web worker is finding the number of permutations, and after it send the result to set a new state in a react component everything is smooth, the console shows the time spent on both process, but when the string is 9 chars or more the rendering hang the browser for 2 sec or more https://all-permutations.surge.sh/
treeshadegit
@treeshadegit
Mar 10 2017 02:24
@adamvz @eyesore- Alright well thanks for the help guys, i'm going to stare at it some more. Hopefully I'm not just dumb and it comes together soon.
CamperBot
@camperbot
Mar 10 2017 02:24
treeshadegit sends brownie points to @adamvz and @eyesore- :sparkles: :thumbsup: :sparkles:
:cookie: 283 | @adamvz |http://www.freecodecamp.com/adamvz
:cookie: 79 | @eyesore- |http://www.freecodecamp.com/eyesore-
Adam VanZuiden
@adamvz
Mar 10 2017 02:25
@treeshadegit No problem. Keep at it!
treeshadegit
@treeshadegit
Mar 10 2017 02:25
Btw this 'eloquent javascript' link looks incredible, good stuff
eyesore-
@eyesore-
Mar 10 2017 02:25
No problem!
gomezd93
@gomezd93
Mar 10 2017 02:28
Hey guys, I have quick question about the "queue" lesson in JS if someone could help. Why is it that I can't return the parameter arr, but I can return it in a function as arr.shift(); or as a variable that has the function assigned to it?
Adam VanZuiden
@adamvz
Mar 10 2017 02:34
@gomezd93 post your code
Adam
@GoingAllTheWayUp
Mar 10 2017 02:34
@gomezd93 got a FCC llink to challenge
arr.shift() may be the special case
It returns what it took off index 0
gomezd93
@gomezd93
Mar 10 2017 02:37
For example, this works:
function nextInLine(arr, item) {
arr.push(item);
return arr.shift();
}
But this does not:
function nextInLine(arr, item) {
arr.push(item);
arr.shift();
return arr;
}
Adam
@GoingAllTheWayUp
Mar 10 2017 02:37
because .shift() returns the value it cuts off the front
and arr returns the array\
The FCC editor wants a specific answer
gomezd93
@gomezd93
Mar 10 2017 02:39
Oh, that makes perfect sense. I was looking at the purpose of the function the wrong way.
Adam
@GoingAllTheWayUp
Mar 10 2017 02:39
they both two other answers not the same answer @gomezd93
gomezd93
@gomezd93
Mar 10 2017 02:39
Thanks!
Adam
@GoingAllTheWayUp
Mar 10 2017 02:39
no prob
not all methods return the same way
thats why its a special case
KatSaldivar
@KatSaldivar
Mar 10 2017 02:43
what does the prototype part of this do? Array.prototype.split
Raja Sharma
@Raja-Sharma
Mar 10 2017 02:43
@KatSaldivar creates an attribute for all objects of that type
KatSaldivar
@KatSaldivar
Mar 10 2017 02:44
@Raja-Sharma so its just a name?
Adam
@GoingAllTheWayUp
Mar 10 2017 02:45
nothing
@KatSaldivar no such thing\
you can split() a string
Luis Felipe López G.
@luishendrix92
Mar 10 2017 02:45
you're referencing the full path of the method; an array has a prototype, the Array prototype, which in turns inherits from the Object prototype (the parent of 'em all)
Adam
@GoingAllTheWayUp
Mar 10 2017 02:45
you can join() an array
Luis Felipe López G.
@luishendrix92
Mar 10 2017 02:46
btw Array.prototype.split doesn't exist
String.prototype.split does
KatSaldivar
@KatSaldivar
Mar 10 2017 02:46
@GoingAllTheWayUp @Raja-Sharma thx
CamperBot
@camperbot
Mar 10 2017 02:46
katsaldivar sends brownie points to @goingallthewayup and @raja-sharma :sparkles: :thumbsup: :sparkles:
:cookie: 295 | @goingallthewayup |http://www.freecodecamp.com/goingallthewayup
:cookie: 124 | @raja-sharma |http://www.freecodecamp.com/raja-sharma
Luis Felipe López G.
@luishendrix92
Mar 10 2017 02:46
but you can create it (which doesn't make sense to me)
Adam
@GoingAllTheWayUp
Mar 10 2017 02:46
prototype is how "they" extended the capablities of javascript at some point in history
Luis Felipe López G.
@luishendrix92
Mar 10 2017 02:47
Array.prototype.split = function() {
  return "This should be illegal in all countries";
};
to refer to the array at hand, you reference it as this
KatSaldivar
@KatSaldivar
Mar 10 2017 02:48
@luishendrix92 I was looking at some hints for the "check for palindromes" challenge and it was listed there. weird. Thx!
CamperBot
@camperbot
Mar 10 2017 02:48
katsaldivar sends brownie points to @luishendrix92 :sparkles: :thumbsup: :sparkles:
:star2: 1421 | @luishendrix92 |http://www.freecodecamp.com/luishendrix92
Adam VanZuiden
@adamvz
Mar 10 2017 02:49
@GoingAllTheWayUp Not quite....prototype is actually a concept of javascript here's a good link that explains it http://javascriptissexy.com/javascript-prototype-in-plain-detailed-language/
Luis Felipe López G.
@luishendrix92
Mar 10 2017 02:49
well yeah, it was listed there haha, but if it actually said Array.prototype.split then you should file an issue on Github
so that they can fix it
Adam
@GoingAllTheWayUp
Mar 10 2017 02:50
@adamvz nice
Usman Akram
@usmanakram1996
Mar 10 2017 02:51
Hey there what level of JS OOP is required by this challenge https://www.freecodecamp.com/challenges/wherefore-art-thou
Adam VanZuiden
@adamvz
Mar 10 2017 02:51
@GoingAllTheWayUp I looked it up a couple of days ago and things made way more sense!
Usman Akram
@usmanakram1996
Mar 10 2017 02:51
i have to take a series of tutorials or i can do it with the material provided with the challenge
?
David Amanze
@GodKingShogun
Mar 10 2017 03:04
hello everyone :smile:
anyone up that can help me finish the sum all prime numbers challenge. i have most of it completed already

function sumPrimes(num) {
 var primeNumbers= [2,3,5];
  var results=0;
  for (var i=7; i==num; i++) {
    if (i%2===0){

    } else {

    }
  }
  for (var j=0; j<primeNumbers.length; j++){
    results+=j;
  }
 return results; 
}
Jason Walker
@jwalker139
Mar 10 2017 03:06
Can someone help me. No matter what values I put in, the percent always prints "0".: int grade, passingGrade = 1, total = 2;
double percent; percent = passingGrade / total;
it still gives me 0 when I do this: percent=1/2;
What am I doing wrong?
David Amanze
@GodKingShogun
Mar 10 2017 03:12
not a lot of people on around this time i guess lol
guess we just have to come back tomorrow
Usman Akram
@usmanakram1996
Mar 10 2017 03:13
@jwalker139 in JS u have to declare variables as var
David Amanze
@GodKingShogun
Mar 10 2017 03:13
@usmanakram1996 think you can take a look at mine too
Usman Akram
@usmanakram1996
Mar 10 2017 03:14
blob
take a look at the screenshot @jwalker139
@GodKingShogun amm let me see
Ken Haduch
@khaduch
Mar 10 2017 03:16
@jwalker139 - this looks strangely like "C"?
Usman Akram
@usmanakram1996
Mar 10 2017 03:16
@GodKingShogun why using two for loops?
lets discuss it :)
so u may get a good idea about what u r doing to get the challenge done
David Amanze
@GodKingShogun
Mar 10 2017 03:17
@usmanakram1996 sorry im back now
Usman Akram
@usmanakram1996
Mar 10 2017 03:18
its ok dude :)
David Amanze
@GodKingShogun
Mar 10 2017 03:18
@usmanakram1996 the first loop is to get all the prime numbers and push it into an array of prime numbers and the second is to loop through the array of prime numbers and add them all up and return
@usmanakram1996 but im not sure how to specify the condition for prime numbers
georgev71
@georgev71
Mar 10 2017 03:19
greetings I need some help with function shout("Hello"){ return Hello+!!!} Its not Correct Im getting a illegal return statement
Richard Belotte
@belotte
Mar 10 2017 03:20

Hello to all. Question. I am getting an error saying this is not a function:

var newInnerStr = newNestedArr[i].splice(0, 1, toUpperCase);

what am I doing wrong?

Matthew
@IMDBLM
Mar 10 2017 03:21
I don't see a function call but I do see a variable @belotte
Usman Akram
@usmanakram1996
Mar 10 2017 03:21
@GodKingShogun see u have to check that the number must either be divisible by the number itself or 1 for the number to be declared as prime :)
just think hope u will reach the solution soon
:)
David Amanze
@GodKingShogun
Mar 10 2017 03:22
@usmanakram1996 well that part would be easy but i need to write a code that sees if the number is only divisible by one and itself which is the part i don't understand how to do
all numbers are divisible by one and itself
Usman Akram
@usmanakram1996
Mar 10 2017 03:24
exactly u have to throw the numbers away which are divisible by any number other than (itself and 1 )
hope u get it
fchen00
@fchen00
Mar 10 2017 03:24
Anybody know why, I stored the value of a key into a dictionary as a integer, but when I printed out, it's not integer but a string
David Amanze
@GodKingShogun
Mar 10 2017 03:25
@usmanakram1996 lol i get the concept but not sure how to write that out in code
Victoria Zambrano
@vzambrano98
Mar 10 2017 03:26
I have found my kryptonite!!! maybe i just don't get jquery as a whole....well i get it but i dont get what to do with the info once i have it maybe? idk if anyone has a sec to take a peak, let me know what i need to go re-research lol
https://codepen.io/vzambrano98/pen/aJmMNa?editors=1010
David Amanze
@GodKingShogun
Mar 10 2017 03:26
@vzambrano98 what are you trying to do
Johnny
@jtan3
Mar 10 2017 03:26
@belotte str.toUpperCase() is how to use .toUpperCase()
Usman Akram
@usmanakram1996
Mar 10 2017 03:27
@GodKingShogun u must grab a piece of paper and try doing some iterations
this will really help u
David Amanze
@GodKingShogun
Mar 10 2017 03:28
@usmanakram1996 i don't see how since i have to pass numbers as high as 977 into the function
Victoria Zambrano
@vzambrano98
Mar 10 2017 03:28
@GodKingShogun okay so, weather app
i'm trying to
1-get the location of the user
2-use that geolocation and give the use the temp, windspeed and himidity
for now lol
So when you click "get weather", all of that plus your city should pop up
fchen00
@fchen00
Mar 10 2017 03:30
I got it, when I used .toFixed() it gives me a string as a return type. That's y it is string in to the dictionary as a string. Thanks guys
Richard Belotte
@belotte
Mar 10 2017 03:32
@IMDBLM the function call (method) is splice.
Johnny
@jtan3
Mar 10 2017 03:33
@vzambrano98 http://ip-api.com/json try for lat and lon
Victoria Zambrano
@vzambrano98
Mar 10 2017 03:34
@jtan3 OMG.....i deleted the code that had that in it..... :worried: thanks lol!
CamperBot
@camperbot
Mar 10 2017 03:34
vzambrano98 sends brownie points to @jtan3 :sparkles: :thumbsup: :sparkles:
:cookie: 335 | @jtan3 |http://www.freecodecamp.com/jtan3
Usman Akram
@usmanakram1996
Mar 10 2017 03:34
i too got stuck :D sorry dude @GodKingShogun
Richard Belotte
@belotte
Mar 10 2017 03:34
@forkerino If I was to do this with out splitting the string, how would I figure out each individual word with out knowing before hand?
Alex G
@glazey132
Mar 10 2017 03:35
Can anyone help with slasher flick?
David Amanze
@GodKingShogun
Mar 10 2017 03:37
@vzambrano98 i think you are accessing the lon and lat wrong. you have cords when it should be coord
Alex G
@glazey132
Mar 10 2017 03:38

function slasher(arr, howMany) {
newArray = [];
newArray.push(arr.splice(howMany));
return newArray;
}

slasher([1, 2, "chicken", 3, "potatoes", "cheese", 4], 5);

Instead of returning something like ["cheese", 4]
it returns [["cheese", 4]
]]*
Johnny
@jtan3
Mar 10 2017 03:40
@glazey132 you're pushing it into and empty []
Alex G
@glazey132
Mar 10 2017 03:40
Is it supposed to be a string instead?
Johnny
@jtan3
Mar 10 2017 03:40
@glazey132 newArrary is an empty [] you created
Alex G
@glazey132
Mar 10 2017 03:41
are you not supposed to use push in this function?
Johnny
@jtan3
Mar 10 2017 03:41
@glazey132 try it and return it with arr only
@glazey132 arr is already in an array
Alex G
@glazey132
Mar 10 2017 03:42
ahh makes sense when you put it that way
thanks @jtan3 !
CamperBot
@camperbot
Mar 10 2017 03:42
glazey132 sends brownie points to @jtan3 :sparkles: :thumbsup: :sparkles:
:cookie: 336 | @jtan3 |http://www.freecodecamp.com/jtan3
Johnny
@jtan3
Mar 10 2017 03:42
@glazey132 welcome
David Amanze
@GodKingShogun
Mar 10 2017 03:45
@usmanakram1996 okay. i think i have figured out a way to do it. let me try and i will tell you if i am successful
JenimDacket
@JenimDacket
Mar 10 2017 03:46

var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

function checkObj(myObj) {

myObj.hasOwnProperty(checkProp);
if (true) {return myObj;}
else {return "Not Found";}
var checkProp = ????;
}

Modify the function checkObj to test myObj for checkProp. If the property is found, return that property's value. If not, return "Not Found".f
This is super confusing
Richard Belotte
@belotte
Mar 10 2017 03:47
@jtan3 I'm not stuck on .toUpperCase(), I'm stuck on splice()
Johnny
@jtan3
Mar 10 2017 03:48
@belotte maybe use splice() first? i know it can't be inside splice()
Alexander Køpke
@alexanderkopke
Mar 10 2017 03:48
@JenimDacket function checkObj(myObj) {<--- here myObj becomes what you pass into the function. Although it has the same name as the object it is a new variable. I think what you pass to the function should be called checkprop
JenimDacket
@JenimDacket
Mar 10 2017 03:50
That didn't work
You mean, set "var checkProp = myObj", right?
Richard Belotte
@belotte
Mar 10 2017 03:51

@jtan3 that doesn't make any sense. I'm not using splice inside of splice. If you look at the code

var newInnerStr = newNestedArr[i][0].splice(0, 1, toUpperCase);

You can see splice is used once. It's being used as according to any documentation I can find.

Johnny
@jtan3
Mar 10 2017 03:53
@belotte what challenge are you doing?
Ken Aguilar
@piq9117
Mar 10 2017 03:53
is that suppose to be inside a loop? whats toUpperCase ?
Richard Belotte
@belotte
Mar 10 2017 03:54

@jtan3 Return the provided string with the first letter of each word capitalized. Make sure the rest of the word is in lower case.

For the purpose of this exercise, you should also capitalize connecting words like "the" and "of".

Remember to use Read-Search-Ask if you get stuck. Write your own code.

Johnny
@jtan3
Mar 10 2017 03:54
@belotte i've never seen toUpperCase inside splice before
eyesore-
@eyesore-
Mar 10 2017 03:55
@belotte You can't call toUpperCase like that. Are you trying to chain your methods?
Richard Belotte
@belotte
Mar 10 2017 03:55
that's my variable name
eyesore-
@eyesore-
Mar 10 2017 03:55
@belotte splice doesn't take a callback.
Alexander Køpke
@alexanderkopke
Mar 10 2017 03:55
@JenimDacket not really. Let me clarify something about functions. Functions are basically blocks of code that you can decide when to run by invoking/calling them.
Richard Belotte
@belotte
Mar 10 2017 03:55
var toUpperCase = newNestedArr[i][0].toUpperCase();
Ken Aguilar
@piq9117
Mar 10 2017 03:56
and its supose to be in a loop yeah?
eyesore-
@eyesore-
Mar 10 2017 03:56
@belotte could you send all your code please?
Jason Walker
@jwalker139
Mar 10 2017 03:57
@khaduch it was c
Alexander Køpke
@alexanderkopke
Mar 10 2017 03:57
@JenimDacket What is great about functions is that you can pass in arguments/parameters.. in this case the function is called checkObj and you pass in a string I think like "gift".. so passing "gift" to the function would look like checkObj("gift");
Richard Belotte
@belotte
Mar 10 2017 03:58
function titleCase(str) {
  var newInnerStr = '';
  var toLowerCase = str.toLowerCase();
  //return toLowerCase;
  var newArr = toLowerCase.split(' ');
  //return newArr
  for(var i = 0; 1 < newArr.length; i++){
    var newNestedArr = newArr[i].split('');
    //return newNestedArr[i][0];
    var toUpperCase = newNestedArr[i][0].toUpperCase();
    //return toUpperCase;
    var newInnerStr = newNestedArr[i][0].splice(0, 1, "toUpperCase");
    return  newInnerStr;
    newInnerStr.join('');
    return newInnerStr;
  }
  return newStr;
}
I have a variable titled "toUpperCase" because that's what it does. Then I am calling that var inside the var that is using the splice.
JenimDacket
@JenimDacket
Mar 10 2017 03:58
@alexanderkopke right, and I get that.
@alexanderkopke The thing that I do not get, that confuses my beyond reason is what we do when we want to write a general assignment/ point the assignment to something outside of the local scope
Alexander Køpke
@alexanderkopke
Mar 10 2017 03:59
@JenimDacket inside the function we need a variable to store what is passed to the function. We decide what this variable is called. function checkObj(checkProp){ <-- here we decided that checkProp is the variable that stores what we pass to the function
eyesore-
@eyesore-
Mar 10 2017 03:59
@belotte You've got a lot going on O.O I think overall you are confusing yourself.
JenimDacket
@JenimDacket
Mar 10 2017 04:00
@alexanderkopke okay... So checkProp is our stand in variable, so to speak
Richard Belotte
@belotte
Mar 10 2017 04:00
@eyesore- Oh for sure confusing my self
the returns are for checking my code @eyesore-
Alexander Køpke
@alexanderkopke
Mar 10 2017 04:01
@JenimDacket ok I just want to make one thing clear. if you call the variable something that already exists like myObj then we no longer have access to myObj from the outside of the function because it has the same name
JenimDacket
@JenimDacket
Mar 10 2017 04:01
@alexanderkopke I thought it could be reassigned locally though...
@alexanderkopke The thing I do NOT understand is what goes inside of the myObj.hasOwnProperty()... I assumed checkProp. If that is correct, then I have no idea how to assign checkProp
Alexander Køpke
@alexanderkopke
Mar 10 2017 04:03
@JenimDacket it can, you can change something on something from the outside but if you have two identical names, one from the outside and one from the function it will pick the one from the function.
JenimDacket
@JenimDacket
Mar 10 2017 04:03
Which we don't want in this case, because we need access to the object...
right?
eyesore-
@eyesore-
Mar 10 2017 04:03
@belotte shoot me a pm with that code and I can walk you through it.
Alexander Køpke
@alexanderkopke
Mar 10 2017 04:03
@JenimDacket right.
JenimDacket
@JenimDacket
Mar 10 2017 04:04
Okay..
Alexander Køpke
@alexanderkopke
Mar 10 2017 04:04
@JenimDacket we need access to the myObj
JenimDacket
@JenimDacket
Mar 10 2017 04:04
okay..
David Amanze
@GodKingShogun
Mar 10 2017 04:04
@alexanderkopke think you can help me with the sum all prime number challenge
JenimDacket
@JenimDacket
Mar 10 2017 04:04
@alexanderkopke
Alexander Køpke
@alexanderkopke
Mar 10 2017 04:04
@JenimDacket ok so what myObj.hasOwnProperty(checkProp) does is, it checks if checkProp exists on myObj
JenimDacket
@JenimDacket
Mar 10 2017 04:05

function checkObj(myObj) {

myObj.hasOwnProperty(checkProp);
if (true) {return myObj;}
else {return "Not Found";}
var checkProp = myObj;

Alexander Køpke
@alexanderkopke
Mar 10 2017 04:05
@JenimDacket myObj.hasOwnProperty(checkProp) this should be used with the if statement
JenimDacket
@JenimDacket
Mar 10 2017 04:06
Either 1. the issue I am having is figuring out how to get back outside of the function to access the obj and try some inputs
Alexander Køpke
@alexanderkopke
Mar 10 2017 04:06
if(myObj.hasOwnProperty(checkProp)){ <-- so in case checkProp exists on myObj it will run the code inside the if statement
JenimDacket
@JenimDacket
Mar 10 2017 04:07
Okay, but the reason that is confusing as hell is b/c checkProp is undefined....
It's a dead end for the system
oh wait.. nvm
So my assignment of var checkProp = myObj is right then?
Alexander Køpke
@alexanderkopke
Mar 10 2017 04:08
@JenimDacket I need to check the instructions. I don't remember all of it
JenimDacket
@JenimDacket
Mar 10 2017 04:09
The instructions are vague as hell and do not explain how .hasOwnProperty works with a function.. >=(
@alexanderkopke Thank you though man. That helps at least some amount. I'll go tinker around and try not to rip my hair out
CamperBot
@camperbot
Mar 10 2017 04:09
jenimdacket sends brownie points to @alexanderkopke :sparkles: :thumbsup: :sparkles:
:star2: 1190 | @alexanderkopke |http://www.freecodecamp.com/alexanderkopke
Alexander Køpke
@alexanderkopke
Mar 10 2017 04:09
Modify the function checkObj to test myObj for checkProp. If the property is found, return that property's value. If not, return "Not Found".
JenimDacket
@JenimDacket
Mar 10 2017 04:10
Okay, how do I assign it to return that property's value when I don't know what that property is?
I can press buttons on the keyboard and complete the challenges, but that is useless if I don't know what I'm doing, ya know?
Alexander Køpke
@alexanderkopke
Mar 10 2017 04:10
@JenimDacket alright, so we have the if statement in place if(myObj.hasOwnProperty(checkProp)){ which runs if checkProp exists on myObj
JenimDacket
@JenimDacket
Mar 10 2017 04:11
And it won't
Alexander Køpke
@alexanderkopke
Mar 10 2017 04:11
now we can deal with returning the property's value
JenimDacket
@JenimDacket
Mar 10 2017 04:11
okay
Hit me
Alexander Køpke
@alexanderkopke
Mar 10 2017 04:12
myObj[checkProp] is how we access the value from inside the function but we need to return it.. so its: return myObj[checkProp]
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
  if(myObj.hasOwnProperty(checkProp)){
 return myObj[checkProp];
}
  return "Change Me!";
}

// Test your code by modifying these values
checkObj("gift");
so this is what we have so far
it checks if what is passed to the function exists on myObj and if it does it returns its value
JenimDacket
@JenimDacket
Mar 10 2017 04:13
But checkProp doesn't mean anything...
David Amanze
@GodKingShogun
Mar 10 2017 04:14
i think i am going to call it a night on the sum all prime number challenge
JenimDacket
@JenimDacket
Mar 10 2017 04:14
That is what I am not getting and what is frustrating me. It literally has no semantic value to the computer
David Amanze
@GodKingShogun
Mar 10 2017 04:14
:cry: :cry: :cry:
Alexander Køpke
@alexanderkopke
Mar 10 2017 04:14
yes it does.. checkObj("gift") <-- this becomes checkProp
"gift" in this case is checkProp
if we did checkObj("pet") checkProp would become "pet"
JenimDacket
@JenimDacket
Mar 10 2017 04:15
I didn't know we could make assignments that way.....
sorry
Okay
Alexander Køpke
@alexanderkopke
Mar 10 2017 04:15
checkObj("bed") now checkProp becomes "bed"
no problem
JenimDacket
@JenimDacket
Mar 10 2017 04:15
I get it now.
Alexander Køpke
@alexanderkopke
Mar 10 2017 04:15
it takes a while to get it
awesome
JenimDacket
@JenimDacket
Mar 10 2017 04:16
Let me restart the challenge and go try it out. I will be back
Alexander Køpke
@alexanderkopke
Mar 10 2017 04:16
good luck!
JenimDacket
@JenimDacket
Mar 10 2017 04:16
Thank you!
Alexander Køpke
@alexanderkopke
Mar 10 2017 04:17
@GodKingShogun is it the sum all primes challenge?
David Amanze
@GodKingShogun
Mar 10 2017 04:18
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      l
@alexanderkopke yes
Alexander Køpke
@alexanderkopke
Mar 10 2017 04:18
@GodKingShogun that is a brain twister for sure. I don't even remember how I did it, just that I had a hard time
JenimDacket
@JenimDacket
Mar 10 2017 04:19
@alexanderkopke So after running .hasOwnProperty("gift"), "gift"'s value will be assigned as the property it corresponds to, yea?
David Amanze
@GodKingShogun
Mar 10 2017 04:19
@alexanderkopke this is what i have so far

function sumPrimes(num) {

 var primeNumbers= [2,3,5];
  var results=0;
  for (var i=7; i==num; i++) {
    if (i%2===0){

    } else {
      for (var k=i-1; k<1; k--){
        var counter=0;
        if (i%k===0) {
         counter+=1; 
        }
       if (counter===0){
          primeNumbers.push(i);
       } else {
         return counter===0;
       }

      }
    }
  }
  for (var j=0; j<primeNumbers.length; j++){
    results+=j;
  }
 return results; 
}
Alexander Køpke
@alexanderkopke
Mar 10 2017 04:19
@JenimDacket it checks if "gift" exists on the myObj object
David Amanze
@GodKingShogun
Mar 10 2017 04:20
i meant this

function sumPrimes(num) {

 var primeNumbers= [2,3,5];
  var results=0;
  for (var i=7; i==num; i++) {
    if (i%2===0){

    } else {
      for (var k=i-1; k>=3; k--){
        var counter=0;
        if (i%k===0) {
         counter+=1; 
        }
       if (counter===0){
          primeNumbers.push(i);
       } else {
         return counter===0;
       }

      }
    }
  }
  for (var j=0; j<primeNumbers.length; j++){
    results+=j;
  }
 return results; 
}
Ken Aguilar
@piq9117
Mar 10 2017 04:21
const checkobj = (obj, checkProp) =>
  obj.hasOwnProperty(checkProp)
    ? obj[checkProp]
    : "change me"
now you can take other objects.. hehe
or curried
const checkobj = obj => checkProp =>
  obj.hasOwnProperty(checkProp)
    ? obj[checkProp]
    : "change me"
JenimDacket
@JenimDacket
Mar 10 2017 04:25
@alexanderkopke did it
Alexander Køpke
@alexanderkopke
Mar 10 2017 04:25
@piq9117 interesting.. so you'd call it with checkobj(myObj)("gift") or how would it work?
JenimDacket
@JenimDacket
Mar 10 2017 04:25
@alexanderkopke I just keep forgetting little things that are ruining my life. Thank you though man.
CamperBot
@camperbot
Mar 10 2017 04:25
jenimdacket sends brownie points to @alexanderkopke :sparkles: :thumbsup: :sparkles:
Alexander Køpke
@alexanderkopke
Mar 10 2017 04:25
@JenimDacket awesome!!
CamperBot
@camperbot
Mar 10 2017 04:25
:warning: jenimdacket already gave alexanderkopke points
Ken Aguilar
@piq9117
Mar 10 2017 04:25
yeah.. exactly.. you can now do partial application or delayed execution.
example
const partiallyApplied = checkobj(somObject)
const gift = partiallyApplied("gift")
const pet = partiallApplied("pet")
const bed = partiallyApplied("bed")
Alexander Køpke
@alexanderkopke
Mar 10 2017 04:27
and then partiallyApplied("gift") or whichever
wow that is powrfull!
Ken Aguilar
@piq9117
Mar 10 2017 04:28
yeah.. its pretty awesome!
Avery Biskup
@fraknard
Mar 10 2017 04:32
http://codepen.io/fraknard/pen/evBQQK?editors=1111 Could someone help me with the posting to twitter part?
JenimDacket
@JenimDacket
Mar 10 2017 04:33
var ourMusic = [
{
"artist": "Daft Punk",
"title": "Homework",
"release_year": 1997,
"formats": [
"CD",
"Cassette",
"LP" ],
"gold": true
}
];
Alexander Køpke
@alexanderkopke
Mar 10 2017 04:35
@GodKingShogun I think I remember some of what I did. I read that all primes except 2 are odd numbers. Which I can see you're implementing. your first if you can have: if(i%2) <--9%2 is 1 which if accepts as true.. 8%2 is 0 which equal false and the if will not run. This way you don't need to make an else
JenimDacket
@JenimDacket
Mar 10 2017 04:35
Why is this written in such a way? Like, why is there a { } within the box brackets, and why does the challenge refer to it as an "array with an object inside"? wth? I thought the object IS the array...
Alexander Køpke
@alexanderkopke
Mar 10 2017 04:35
@alexanderkopke it is more readable
Ken Aguilar
@piq9117
Mar 10 2017 04:35
in javascript everything is an object
objects are key - value pairs
an array's key - value pair is the index and its value
JenimDacket
@JenimDacket
Mar 10 2017 04:36
Okay.
Ken Aguilar
@piq9117
Mar 10 2017 04:36
and that is just to structure the data.. you could have several of those objects inside
JenimDacket
@JenimDacket
Mar 10 2017 04:36
I think it was just a confusing way to write that. "contains AN object"
that had me thinking I haven't learned anything
Ken Aguilar
@piq9117
Mar 10 2017 04:37
hahah.. yeah.. dude.. thats a usual feeling
remember that we programmers are expert googlers! so just know what to google
JenimDacket
@JenimDacket
Mar 10 2017 04:38
I keep coming up with lots of unhelpful results... haha
Ken Aguilar
@piq9117
Mar 10 2017 04:38
especially the dreaded undefined is not a function?
hahah
i still see that everyday
Andrew Shieh
@andrewlikes
Mar 10 2017 04:43
@piq9117 i'm glad i'm not the only one
str.reverse() is not a function
blah blah blah is not a function
Ken Aguilar
@piq9117
Mar 10 2017 04:43
hahah
or NaN
Andrew Shieh
@andrewlikes
Mar 10 2017 04:44
haven't run into that yet lol
Ken Aguilar
@piq9117
Mar 10 2017 04:44
sooner or later you'll bump into it.. lol..
JenimDacket
@JenimDacket
Mar 10 2017 04:46
Why does this unrecoverable item/syntax thing happen..........
Brandon Achu
@bachu-dev
Mar 10 2017 04:47
Does any1 here know Ruby on Rails?
Neous1
@Neous1
Mar 10 2017 04:48
check your closing brackets
@JenimDacket check your closing brackets
JenimDacket
@JenimDacket
Mar 10 2017 04:48
That isn't the issue
It says "unrecoverable syntax 53%"
ANYTHING I change will still be incorrect.
I have to completely wipe everything I wrote and restart. Copying and pasting yields the same problem.
Neous1
@Neous1
Mar 10 2017 04:49
lets' check your codes
JenimDacket
@JenimDacket
Mar 10 2017 04:50
maybe b/c I write in mandarin?
Neous1
@Neous1
Mar 10 2017 04:50
sorry can't read mandarin
JenimDacket
@JenimDacket
Mar 10 2017 04:52
var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}
{
"artist":"草东没有排队",
"title":"大风吹",
"realease_year":2015
"formats":[
"LP",
"CD",
"MP3"
]
}
]
I don't think you are understanding me
The system is giving back a response of "unrecoverable syntax" with a %. It's not an error message indicating I need to change something
Ken Aguilar
@piq9117
Mar 10 2017 04:55
huh.. can't say i've ever seen such an error before.. you seriously write in mandarin? maybe its related to that?
JenimDacket
@JenimDacket
Mar 10 2017 04:55
yeah.. I thought so too, but then I changed it and its still doing it
Ken Aguilar
@piq9117
Mar 10 2017 04:56
looks like some missing brackets.. i pasted it on my console
Johnny
@jtan3
Mar 10 2017 04:57
@JenimDacket missing a comma after 2015
Ken Aguilar
@piq9117
Mar 10 2017 04:57
there you go
var myMusic = [{
  "artist": "Billy Joel",
  "title": "Piano Man",
  "release_year": 1973,
  "formats": ["CS", "8T", "LP" ],
  "gold": true
},{
  "artist":"草东没有排队",
  "title":"大风吹",
  "realease_year":2015,
  "formats":["LP", "CD", "MP3"]
}];
myleskilos
@myleskilos
Mar 10 2017 04:59
On the Cesar's Cipher question. My code is decoding the message to 'F8EE C5DE CAM6'. Looks like Im close, but some letters are not coming out. Can anyone give me a hand?
function rot13(str) { 

  var result = '';
  var charNum;
  //var test = 'R';
  //return test.charCodeAt(0);
  //return String.fromCharCode(56);  

  for (i = 0; i < str.length; i++){
    if (str[i] != ' ' && str[i] != '!' && str[i] != '?' && str[i] != '.') {
      charNum = str.charCodeAt(i);
      result += String.fromCharCode(charNum-13);
    } else {

      result += str[i];
    }

  }
  return result;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC"); //Returns 'F8EE C5DE CAM6'
Neous1
@Neous1
Mar 10 2017 05:01
@JenimDacket there is comma missing after 2015
and a semicolon at the end your 2nd object
JenimDacket
@JenimDacket
Mar 10 2017 05:04
Again guys, didn't solve the problem
Ken Aguilar
@piq9117
Mar 10 2017 05:06
what is it saying now?
same err message?
JenimDacket
@JenimDacket
Mar 10 2017 05:06
Exact same
heroiczero
@heroiczero
Mar 10 2017 05:06
@myleskilos if your charCodeAt is less than 65 you have to subtract 13 and a-13>65 then you add 13 or you will get non alphabetical characters
Ken Aguilar
@piq9117
Mar 10 2017 05:07
var myMusic = [{
  "artist": "Billy Joel",
  "title": "Piano Man",
  "release_year": 1973,
  "formats": ["CS", "8T", "LP" ],
  "gold": true
},{
  "artist":"草东没有排队",
  "title":"大风吹",
  "realease_year":2015,
  "formats":["LP", "CD", "MP3"]
}];
have you tried copy and pasting this on ur console? does it give you an error or just undefined?
myleskilos
@myleskilos
Mar 10 2017 05:10
@heroiczero how do you find that information? I was looking for a list of the codes but none of the lists I found matched up
heroiczero
@heroiczero
Mar 10 2017 05:11
Akash Kumar Verma
@AkashKumarVerma
Mar 10 2017 05:16
@myleskilos can you give the input which is causing the problem
Chris Cullen
@123xylem
Mar 10 2017 05:18

https://ide.c9.io/clayton901/webdevlearning
Can you see why my grid has a gap in the middle?
Heres my .css

 body{color:black;
        margin:0 auto;
    background-image:url("https://img.clipartfest.com/c69013f7236a2f4881880c306e4a042f_-african-animal-cartoon-clipart-jungle-animals-background_1300-976.jpeg");
        background-size:cover;
    }


    .image{
    max-width:300px; max-height:150px;
    float:left;
    margin:5px 5px 5px 5px;
    border:1px solid grey;
}

     .title{
         border-radius:10%;
         background-color:white;
        text-align: center;
        text-decoration: underline;
        margin-right:35%;
        margin-left:35%;
    }

    .text{
        text-align: center;
    }

    .inline{
        display: inline;
    }

     .row.form{
        width:30%;
        margin:0 33% 33% 0;
        text-align:center;
    }

And heres my html

<%include partials/header%>
<h1 class=" title">The Animal Blog</h1>

<div class="container main">
    <div class="row ">

    <%animals.forEach(function(animal){%>   
    <div class="col-lg-6">
        <div class="thumbnail">
    <image  class="image" src="<%=animal.image%>"> </image>
        <div class="text">

            <h3>Name: <%=animal.name%></h3>
            <p>Habitat: <%=animal.home%></p>
            <p>Description: <%=animal.moreInfo%></p>
             <br>
              <form class="inline" action="/animals/<%=animal.id%>/?_method=DELETE" method="POST">
    <button class="btn btn-default btn-primary">Delete Animal!</button>
<a class=" btn btn-default btn-primary" href="/animals/<%=animal.id%>/edit">Edit</a>

</form> 
 </div>

      </div>        
  </div>
   <% }); %>
</div>
        </div>

<%include partials/footer%>
Peng Xianyao
@pengxianyao
Mar 10 2017 05:19

hi, can anyone help me understand why:

function caseInSwitch(val) {
var answer = "";
// Only change code below this line
switch (val) {
case 1:
return "alpha";
break;
case 2:
return "beta";
break;
case 3:
return "gamma";
break;
case 4:
return "delta";
break;

gives me an [Unreachable 'break' after 'return' ] yellow error on all the [break;] lines?

Andrew Shieh
@andrewlikes
Mar 10 2017 05:20
function chunkArrayInGroups(arr, size) {

  var newArray = [''];

  newArray = arr.push("hello");



  return newArray; //returns value of 5, why?
}

chunkArrayInGroups(["a", "b", "c", "d"], 0);
Just a curious question, I thought .push() was supposed to add an element to the end of a string. Why is it returning a value of 5 instead of the new string?
@pengxianyao what's the name of that challenge?
I think it's something to do with your format
Manish Giri
@Manish-Giri
Mar 10 2017 05:21
@andrewlikes .push() returns the new length of the array.
after adding.
@pengxianyao your case statements are wrong
Andrew Shieh
@andrewlikes
Mar 10 2017 05:22
ah okay thx @Manish-Giri
CamperBot
@camperbot
Mar 10 2017 05:22
andrewlikes sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 4688 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Mar 10 2017 05:22
@pengxianyao inside each case, you assign the right string to answer..
@andrewlikes :+1:
Peng Xianyao
@pengxianyao
Mar 10 2017 05:23
@andrewlikes Selecting from many options with Switch Statements
@Manish-Giri okay ill look around, thanks!
CamperBot
@camperbot
Mar 10 2017 05:23
pengxianyao sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 4689 | @manish-giri |http://www.freecodecamp.com/manish-giri
SaiChand Duppala
@saichandd
Mar 10 2017 05:24
Will running an infinite loop for animations with setTimeOut cause problems?
Peng Xianyao
@pengxianyao
Mar 10 2017 05:30
@Manish-Giri okay i managed to get it. was a little confused because of an example i saw on w3schools where there were two variables instead of one in the function line.
@Manish-Giri thanks mate
CamperBot
@camperbot
Mar 10 2017 05:30
pengxianyao sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:warning: pengxianyao already gave manish-giri points
Manish Giri
@Manish-Giri
Mar 10 2017 05:31
@pengxianyao welcome
Altan Sahin
@AldoSahin
Mar 10 2017 05:41

Hi all, I am stuck with the factorialize a number lesson...
```//
function factorialize(num) {

for (var i=1; i<=num; i++){
num *= i;
}

return num;
}

factorialize(5);

function factorialize(num) {

 for (var i=1; i<=num; i++){
   num *= i;
 }

  return num;
}

factorialize(5);
Greatful for any suggestions...
AKS
@amitkumarsarangi
Mar 10 2017 05:42
@AldoSahin what is your issue
Altan Sahin
@AldoSahin
Mar 10 2017 05:42
@amitkumarsarangi
I am beeing told that there is a potential infinite loop at line 5
AKS
@amitkumarsarangi
Mar 10 2017 05:43
@AldoSahin yes
@AldoSahin you are doing i<=num and then doing num*=i
Altan Sahin
@AldoSahin
Mar 10 2017 05:44
@amitkumarsarangi I don't understand why???
AKS
@amitkumarsarangi
Mar 10 2017 05:44
@AldoSahin you increasing the num after every loop
Joseph
@revisualize
Mar 10 2017 05:44
Hi.
AKS
@amitkumarsarangi
Mar 10 2017 05:44
@AldoSahin do you see y u are getting into an infinite loop
@revisualize hi
Altan Sahin
@AldoSahin
Mar 10 2017 05:45
I thought the last line is limiting Factorialize(5) to num 5
AKS
@amitkumarsarangi
Mar 10 2017 05:46
@AldoSahin num gets 5... in your for loop you are comparing i with num... but in your loop you are increasing the value of num
@AldoSahin tell me what is the value of num after first iteration (loop)
Altan Sahin
@AldoSahin
Mar 10 2017 05:47
2
?
AKS
@amitkumarsarangi
Mar 10 2017 05:47
No my friend @AldoSahin
heroiczero
@heroiczero
Mar 10 2017 05:48
@AldoSahin num keeps on increasing when you keep on multiplying it
AKS
@amitkumarsarangi
Mar 10 2017 05:48
see what is the statement inside the loop @AldoSahin
Altan Sahin
@AldoSahin
Mar 10 2017 05:49
Sorry I don't get it...
natural data corruption
@primaveraentalca
Mar 10 2017 05:49
hi, guys. i'm doing the "Wherefore art thou" challenge, can somebody tell what i'm i doing wrong?
function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line
  var keys = Object.keys(source);

  keys.forEach(function(key){
    collection.forEach(function(object){
      if(object[key]==source[key]&&arr.indexOf(object)<0){
        arr.push(object);
      }
    });
  });
  // Only change code above this line
  return arr;
}
AKS
@amitkumarsarangi
Mar 10 2017 05:50
@AldoSahin after you get into the for loop you are increasing the value of num much more than the value of i.... and this never ends.. therefore infinite loop
Altan Sahin
@AldoSahin
Mar 10 2017 05:51
Ok, that means I need an additional varriable correct?
AKS
@amitkumarsarangi
Mar 10 2017 05:51
@AldoSahin yes
Altan Sahin
@AldoSahin
Mar 10 2017 05:52
Thank you very much AKS
AKS
@amitkumarsarangi
Mar 10 2017 05:52
do not use num to store
Altan Sahin
@AldoSahin
Mar 10 2017 05:52
OK, I will change this and come back in a couple of minutes.
function factorialize(num) {
 var count = 1;
 for (var i=1; i<=num; i++){
   count *= i;
 }

  return count;
}

factorialize(5);
Thank you @amitkumarsarangi
CamperBot
@camperbot
Mar 10 2017 05:54
aldosahin sends brownie points to @amitkumarsarangi :sparkles: :thumbsup: :sparkles:
:cookie: 305 | @amitkumarsarangi |http://www.freecodecamp.com/amitkumarsarangi
AKS
@amitkumarsarangi
Mar 10 2017 05:55
@primaveraentalca you need to see if there is a property present
@AldoSahin nice
Ayush Bahuguna
@relentless-coder
Mar 10 2017 05:57
is anyone here good with angular js? There's no one in the angular js room and this is urgent
natural data corruption
@primaveraentalca
Mar 10 2017 06:04
@amitkumarsarangi i dont know why this pushes objects it doesn't suppose to
function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line
  var keys = Object.keys(source);

  collection.forEach(function(object){
    keys.forEach(function(key){
      if(object.hasOwnProperty(key)&&object[key]==source[key]&&arr.indexOf(object)<0){
        arr.push(object);
      }
    });
  });
  // Only change code above this line
  return arr;
}

whatIsInAName([{ "a": 1, "b": 2 }, { "a": 1 }, { "a": 1, "b": 2, "c": 2 }], { "a": 1, "c": 2 });
it works for the first two tests
Markus Kiili
@Masd925
Mar 10 2017 06:09
@primaveraentalca Using filter and every methods would be easier.
You are pushing if the property values match for one source key. You should be pushing if they match for all the source's keys.
You can use a flag variable or better suited iterator.
natural data corruption
@primaveraentalca
Mar 10 2017 06:13
what do you mean flag variable??
Markus Kiili
@Masd925
Mar 10 2017 06:14
@primaveraentalca A boolean value that tells if property values of object and source have matched so far.
After looping all the keys, you can check the flag and push if it is true.
MrityunjaiMishra
@MrityunjaiMishra
Mar 10 2017 06:17
i m having problem with escape sequences
natural data corruption
@primaveraentalca
Mar 10 2017 06:17
@Masd925 how can i do that??
heroiczero
@heroiczero
Mar 10 2017 06:18
@MrityunjaiMishra remove spaces or in your code
MrityunjaiMishra
@MrityunjaiMishra
Mar 10 2017 06:18
ohk
thanks @heroiczero
CamperBot
@camperbot
Mar 10 2017 06:19
mrityunjaimishra sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
:cookie: 955 | @heroiczero |http://www.freecodecamp.com/heroiczero
MrityunjaiMishra
@MrityunjaiMishra
Mar 10 2017 06:19
can u tell me about carriage return
Markus Kiili
@Masd925
Mar 10 2017 06:19
@primaveraentalca For each object, initialize a variable to true like var allMatched = true;. Then loop all the source's keys, and if you find one for which the property key doesn't exist or values don't match, set the flag to false. After key loop, check the flag and push the object if the flag is true.
Basic loop logic for checking if many conditions hold.
MrityunjaiMishra
@MrityunjaiMishra
Mar 10 2017 06:27
i am again having a problem with the javascript

// Example
var ourStr = "I come first. " + "I come second.";

// Only change code below this line

var myStr;
myStr = "This is the start." + "This is the end.";

this is the code
The result is
myStr = "This is the start."+"This is the end.";
but it should be
This is the start. This is the end.
JuicyITer
@juicyiter
Mar 10 2017 06:33
@joreyesl thanks
CamperBot
@camperbot
Mar 10 2017 06:33
ethanman sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 580 | @joreyesl |http://www.freecodecamp.com/joreyesl
JuicyITer
@juicyiter
Mar 10 2017 06:36
hey guys , i really wanna know how to input my code in formats not just ordinary words
just like that kind of type with black background
CamperBot
@camperbot
Mar 10 2017 06:37
:bulb: to format code use backticks! ``` more info
JuicyITer
@juicyiter
Mar 10 2017 06:38
i meant when its typed in our chatroom
got it hh
Jor
@joreyesl
Mar 10 2017 06:41
:thumbsup:
JuicyITer
@juicyiter
Mar 10 2017 06:41
here comes my questions ^_^
var Car = function(wheels, seats, engines) {
  //Change this constructor
  this.wheels = 4;
  this.seats = 5;
  this.engines = 1;
};

//Try it out here
var myCar = new Car(2,1,2);
it didnt work out...
i did it as the instruction told, but it didnt work out as i expected
natural data corruption
@primaveraentalca
Mar 10 2017 06:45
@Masd925 finally i think i got it, thanks
CamperBot
@camperbot
Mar 10 2017 06:45
primaveraentalca sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 3555 | @masd925 |http://www.freecodecamp.com/masd925
JuicyITer
@juicyiter
Mar 10 2017 06:45
i just output
Jor
@joreyesl
Mar 10 2017 06:46

@ethanman you have it hardcoded, you need to use the parameters.
Ex:

var Car = function(wheels) {
  //Change this constructor
  this.wheels = wheels; // <--- needs to be set to the parameter
};

when you do new Car(2,1,2); you are passing in 2,1,2 to wheels,seats,engines and you set those in the constructor.

JuicyITer
@juicyiter
Mar 10 2017 06:46
{"wheels":4,"seats":5,"engines":1}
atogz
@atogz
Mar 10 2017 06:49
Hello guys. I need help with such piece of code https://jsfiddle.net/5yprpjvc/2/ . What i want to achieve - is to disable button when value is 0 and enable it if its more than 0.
Disable part works, but if i press plus and increase quantity, the button remains disabled
Can someone point on my mistake, please? :)
Randy Pratt
@illcrx
Mar 10 2017 06:50

Hey, Ive been having a hard time with this, problem 211.

  for(var i = 0; i < arr.length; i++){
    for(var ii = 0; i< arr[i].length; ii++){
      product *= product[i][ii];
    }
  }

Its supposed to multiply

multiplyAll([[1,2],[3,4],[5,6,7]]);
CamperBot
@camperbot
Mar 10 2017 06:50
:bulb: to format code use backticks! ``` more info
Markus Kiili
@Masd925
Mar 10 2017 06:51
@illcrx You need to access arr. Product is most likely just a number.
JuicyITer
@juicyiter
Mar 10 2017 06:51
o i see, am i supposed to change the parameters inside the function too?
atogz
@atogz
Mar 10 2017 06:51
ah nvm, had to use removeAttr and not .attr
Randy Pratt
@illcrx
Mar 10 2017 06:51
ah that makes sense
JuicyITer
@juicyiter
Mar 10 2017 06:51
got it ,thanks jor @joreyesl
CamperBot
@camperbot
Mar 10 2017 06:51
ethanman sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:warning: ethanman already gave joreyesl points
JuicyITer
@juicyiter
Mar 10 2017 06:53
man, you helped me a lot today. THANKS again
Alexey Saksin
@akavato
Mar 10 2017 07:16

Hello everybody! could some one help me explain how to fix my condition expressions, here is the code
```function mutation(arr) {
var str = arr[0].toLowerCase();
var letters = arr1.toLowerCase();
var letArray = letters.split('');

for(i=0;i < letArray.length; i++){
var existance = str.indexOf(letArray[i]);

if(existance === -1){
  return false;
}
else if(existance !== -1 && i != letArray.length){
  continue;
}
else if(existance !== -1 && i == letArray.length){
  return true;
}

}

}
```

badalsaibo
@heyDante
Mar 10 2017 07:18
@akavato var letters = arr1.toLowerCase();
Alexey Saksin
@akavato
Mar 10 2017 07:19
markdown eat []
badalsaibo
@heyDante
Mar 10 2017 07:28
@akavato i think true should be returning outside the loop
Markus Kiili
@Masd925
Mar 10 2017 07:30
@akavato No need for arrays here. String characters can be looped and indexOf works on strings.
Alexey Saksin
@akavato
Mar 10 2017 07:31
@heyDante yeah, it works, thanks)
CamperBot
@camperbot
Mar 10 2017 07:31
akavato sends brownie points to @heydante :sparkles: :thumbsup: :sparkles:
:cookie: 553 | @heydante |http://www.freecodecamp.com/heydante
Alexey Saksin
@akavato
Mar 10 2017 07:33
@Masd925 tried without an array, but indexOf worked on the whole word, but not every letter(
Markus Kiili
@Masd925
Mar 10 2017 07:33
@akavato You can use .charAt(i) to get one looped letter and check it.
Daniel
@OldRainBlaze
Mar 10 2017 07:33
Inside function fun1, assign 5 to oopsGlobal without using the var keyword. How is this done?
badalsaibo
@heyDante
Mar 10 2017 07:34
@Masd925 You know any resources to learn JSON, API?
Alexey Saksin
@akavato
Mar 10 2017 07:35
@Masd925 thanks! i'll try this method
CamperBot
@camperbot
Mar 10 2017 07:35
akavato sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 3556 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Mar 10 2017 07:35
@heyDante Do you mean the backend or the browser JS part?
badalsaibo
@heyDante
Mar 10 2017 07:36
kinda beginner
Travis Fry
@definistrate1ster
Mar 10 2017 07:36
Can someone help me please? I have no idea how to convert celsius to Fahrenheit
function convertToF(celcius) {
  var fahrenheit;
  // Only change code below this line
var quotient = 9 / 5;
  var sum = 0 + 32;


  // Only change code above this line
  return fahrenheit;
}

// Change the inputs below to test your code
convertToF(-30);
Markus Kiili
@Masd925
Mar 10 2017 07:37
@heyDante MDN and W3Schools have material on how to get JSON using AJAX call.
@definistrate1ster fahrenheit = ... <- use celsius here
Daniel
@OldRainBlaze
Mar 10 2017 07:40
Inside function fun1, assign 5 to oopsGlobal without using the var keyword. how is this done?
antoine serveaux
@erathostene
Mar 10 2017 07:49
Hi there. Ok i give up, does anyone know how to display 2 decimal digits (with trailing zeros if needed) ? I know i can use toFixed or to Precision but they output string and the exact change challenge seems to expect number (anyone backward conversion i attempted with Number or parseFloat from toFixed or toPrecision removed the trailing zeros)
Travis Fry
@definistrate1ster
Mar 10 2017 07:52
@Masd925 Thanks. Is this what you mean?
function convertToF(celsius) {
  var fahrenheit;
  // Only change code below this line
  celcius = (9 / 5 + 32); 


  // Only change code above this line
  return fahrenheit;
}

// Change the inputs below to test your code
convertToF(0);
CamperBot
@camperbot
Mar 10 2017 07:52
definistrate1ster sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 3557 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Mar 10 2017 07:55
@erathostene If you are doing Exact change, you are not expected to format the numbers. 2 and 2.00 are the same number. You can only format strings. Numbers you can round with:
var num = 1.23456;
Number(num.toFixed(2)); // 1.23
So it the numbers are right, the challenge passes regardless of how the numbers are displayed.
If it doesn't pass, there is some other problem.
王乃坤
@Cnwn
Mar 10 2017 08:01
I can't think of the question at 21。。
antoine serveaux
@erathostene
Mar 10 2017 08:03
@Masd925 HOOOO right thx i didn't check my answer correctly, i was one penny off. Thanks a lot, i was going mad.
CamperBot
@camperbot
Mar 10 2017 08:03
erathostene sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 3558 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Mar 10 2017 08:05
@erathostene Only robust way to avoid float rounding problems is to use penny amounts that are safe integers.
kishore sriramula
@KISHORESSK
Mar 10 2017 08:11

function abTest(a, b) {
// Only change code below this line

if (a < 0 || b < 0); {
return undefined;
}

return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));

// Only change code above this line

}

// Change values below to test your code
abTest(2,2);

anything wrong with above code ?
Manish Giri
@Manish-Giri
Mar 10 2017 08:13
@KISHORESSK remove the ;
after if
Jor
@joreyesl
Mar 10 2017 08:13
@KISHORESSK yes, you have ; in the wrong place in if (a < 0 || b < 0); {. You should delete it
antoine serveaux
@erathostene
Mar 10 2017 08:14
@Masd925 Indeed i was logging those math and just noticed how they went off (1.7399999999999949 instead of 1.74..)
Markus Kiili
@Masd925
Mar 10 2017 08:15
@erathostene Yes, that is why money is not really stored in floats. You can use penny amounts that are integers without rounding problems, you you can cook up some rounding scheme or margin of error on comparisons there.
antoine serveaux
@erathostene
Mar 10 2017 08:22
@Masd925 OK i'll work on that thx
CamperBot
@camperbot
Mar 10 2017 08:22
erathostene sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: erathostene already gave masd925 points
OGKevin
@OGKevin
Mar 10 2017 08:49
hello
Bartosz
@CataciD
Mar 10 2017 08:50
mates, do the last es6 challanges in the beta work? with the import/export etc
or do i have to do something before I try em, cause node thingers don't work in browser ;x
Ogundele Olumide
@Lumexralph
Mar 10 2017 08:50
@Masd925 @Manish-Giri good morning :wave:
Markus Kiili
@Masd925
Mar 10 2017 08:50
@Lumexralph Hello.
ulf
@ulf1
Mar 10 2017 08:51
the fcc website is down
Ogundele Olumide
@Lumexralph
Mar 10 2017 08:51
@Masd925 Hello ? :smirk:
OGKevin
@OGKevin
Mar 10 2017 08:55
@ulf1 how youy mean ?
ulf
@ulf1
Mar 10 2017 08:55
@OGKevin offline
Yousfi Soufiane
@YOUSFISoufiane
Mar 10 2017 08:55
hello , the "declare javascript variable" stuck on submiting !
OGKevin
@OGKevin
Mar 10 2017 08:55
well im on it just refreshed and viewued other challanges seems to work fine on my end
@YOUSFISoufiane post your code :)
Ogundele Olumide
@Lumexralph
Mar 10 2017 08:56
@YOUSFISoufiane what are you to do and what have you done?
Markus Kiili
@Masd925
Mar 10 2017 08:56
@Lumexralph I think it is around 60/30/10% of Hello/yo/yoyo! so not that dramatic.
Yousfi Soufiane
@YOUSFISoufiane
Mar 10 2017 08:56
no its just the begining " var myName;" then it doesnt want to pass to the other challenge
Ogundele Olumide
@Lumexralph
Mar 10 2017 08:57
@Masd925 :laughing:
@YOUSFISoufiane can you show your code?
Yousfi Soufiane
@YOUSFISoufiane
Mar 10 2017 08:58
"var myName;" that's the code lool , maybe it's a probleme of connection , I wanna move on quick ..
anyway I'll try with my connexion
OGKevin
@OGKevin
Mar 10 2017 08:58
@YOUSFISoufiane ucan u then make a screen shot becasue this is still vague
Yousfi Soufiane
@YOUSFISoufiane
Mar 10 2017 08:58
ok
OGKevin
@OGKevin
Mar 10 2017 08:59
@YOUSFISoufiane prefereably with the check list at the bottem
OGKevin
@OGKevin
Mar 10 2017 09:10
@Masd925 u here ?
Kshitij Bisht
@Kshitij001
Mar 10 2017 09:15
help needed
OGKevin
@OGKevin
Mar 10 2017 09:16
@Kshitij001 what challange ?
Kshitij Bisht
@Kshitij001
Mar 10 2017 09:16
In condense array with reduce
OGKevin
@OGKevin
Mar 10 2017 09:17
@Kshitij001 what have you coded so far ?
and did u read the reduce docs ?
kishore sriramula
@KISHORESSK
Mar 10 2017 09:39
@Manish-Giri thanks @joreyesl thanls
CamperBot
@camperbot
Mar 10 2017 09:39
kishoressk sends brownie points to @manish-giri and @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 581 | @joreyesl |http://www.freecodecamp.com/joreyesl
:star2: 4691 | @manish-giri |http://www.freecodecamp.com/manish-giri
AlexFlakes
@AlexFlakes
Mar 10 2017 10:13

Hey Guys, ot kind of stuck at the freecodecamp Javascript Escape Characters Challenge. I am supposed to have 3 lines with text, but I'm not sure why my escape characters are not being registered. Here is the code:

var myStr = "FirstLine \n \ SecondLine \ \r ThirdLine"; // Change this line

Cristian
@Ccastillo06
Mar 10 2017 10:14
var myStr = "FirstLine \n \ SecondLine \ \r ThirdLine" ??
oops var myStr = "FirstLine \n \ SecondLine \ \r ThirdLine"
what it doesn't send it
AlexFlakes
@AlexFlakes
Mar 10 2017 10:15
The challenge describes how it should be written like this : FirstLine newline backslash SecondLine backslash carriage-return ThirdLine
oldwangnextdoor
@oldwangnextdoor
Mar 10 2017 10:16
Help!The 216th project,Using Objects for Lookups
Ghulam Shabir
@ghulamshabir
Mar 10 2017 10:16
@AlexFlakes @Ccastillo06 remove spaces
AlexFlakes
@AlexFlakes
Mar 10 2017 10:16
Just a second
oldwangnextdoor
@oldwangnextdoor
Mar 10 2017 10:16
I don't know how to solve that
Cristian
@Ccastillo06
Mar 10 2017 10:16
var myStr ="FirstLine\n\SecondLine\\rThirdLine";
AlexFlakes
@AlexFlakes
Mar 10 2017 10:16
That did it! Thanks Ghulam!
And thanks Cristian!
Cristian
@Ccastillo06
Mar 10 2017 10:17
the thing is I did it but when i send into chat
the like changes
Ghulam Shabir
@ghulamshabir
Mar 10 2017 10:17
@AlexFlakes :+1:
Cristian
@Ccastillo06
Mar 10 2017 10:17
@AlexFlakes nice one! I don't know why my solution changes when i press enter into chat :S
Ghulam Shabir
@ghulamshabir
Mar 10 2017 10:20
@Ccastillo06 \ is also used by gitter for escaping backticks and other symbols, you can put backticks around the code to prevent gitter do it like this `code` then it would appear like this code
Rohit Sachdeva
@ehrohit
Mar 10 2017 10:35
Title Case a Sentence can somebody help me with this
basci algorithm if completed
itsthomas
@itsthomas
Mar 10 2017 10:39
We import JavaScript files like this:
'''
@import "vendor/jquery-1.9.1.min.js";
@import "vendor/jquery.cookie.js";
@import "vendor/foundation.js";
@import "vendor/foundation-events.js";
@import "vendor/slick.js";
'''
CamperBot
@camperbot
Mar 10 2017 10:39
:bulb: to format code use backticks! ``` more info
Ghulam Shabir
@ghulamshabir
Mar 10 2017 10:40
@ehrohit what you have ?
itsthomas
@itsthomas
Mar 10 2017 10:41
We import JavaScript files like this:
'''
@import "vendor/jquery-1.9.1.min.js";
@import "vendor/jquery.cookie.js";
@import "vendor/foundation.js";
@import "vendor/slick.js";
'''
However I need to import slick.js only if it's needed. To do so I changed the above code to this:
'''
@import "vendor/jquery-1.9.1.min.js";
@import "vendor/jquery.cookie.js";
@import "vendor/foundation.js";
if (document.querySelector('.carousel') !== null) {
@import "vendor/slick.js";
}
'''
But still even if there's no .carousel on the page, the slick.js get loaded. What am I doing wrong?
CamperBot
@camperbot
Mar 10 2017 10:41
:bulb: to format code use backticks! ``` more info
Dan Couper
@DanCouper
Mar 10 2017 10:42
@itsthomas what's that wierd import syntax from?
itsthomas
@itsthomas
Mar 10 2017 10:43
@DanCouper It's a js file for loading vendor js files.
Dan Couper
@DanCouper
Mar 10 2017 10:47
In what program though? Cos that's how you import CSS, I assumed it was some specific wierd syntax in a program
Kamal Loudiyi
@kaloudiyi
Mar 10 2017 10:48
Hi,
Dan Couper
@DanCouper
Mar 10 2017 10:48
Normal JS imports don't look like that, and neither does CommonJS' require
Kamal Loudiyi
@kaloudiyi
Mar 10 2017 10:49

Hi I have the function in javascript exercise : function lookUpProfile(firstName, prop) {
// Only change code below this line
var i=0;
while(i < contacts.length)
{
if(contacts[i].firstName == firstName ) {
if( contacts[i].hasOwnProperty(prop)) {
return(contacts[i].prop);
} else {
return("No such property");
}
}
i++;
}
return("No such contact");

// Only change code above this line
}

It's don't work well, any idea ?
the0ffh
@the0ffh
Mar 10 2017 10:51

Hello!
Could someone explain me why my the following code freezes my browser?

function sumPrimes(num) {
  var acc = [];


  for(var i=0; i<num;i++){
   for(var j=0; j<num;j++){
    acc.push("i:"+i+" j:"+j);
    } 
  }

  return acc;
}
sumPrimes(10);

it does not happen when num is replaced by a number within loops

Dan Couper
@DanCouper
Mar 10 2017 10:53
@kaloudiyi You're returning immediately, so if the first object in the array isn't the one you want, it will exit before the loop reaches the one you do want; it will only ever check the first item
Aliaksandr_Pitkevich
@anfield343
Mar 10 2017 10:54
@the0ffh as for me, i don`t understand what the problem
the0ffh
@the0ffh
Mar 10 2017 10:56
@anfield343 I admit it is very strange to me [despite i am really new to js]
Kamal Loudiyi
@kaloudiyi
Mar 10 2017 10:56
@DanCouper No, I return immediately after matching the right first name, else i still loop !
Aliaksandr_Pitkevich
@anfield343
Mar 10 2017 10:57
@the0ffh your code works correctly
@the0ffh without mistake
s
the0ffh
@the0ffh
Mar 10 2017 10:58
@anfield343 then my computer is the problem:/ Thanks for checking!
CamperBot
@camperbot
Mar 10 2017 10:58
the0ffh sends brownie points to @anfield343 :sparkles: :thumbsup: :sparkles:
:cookie: 20 | @anfield343 |http://www.freecodecamp.com/anfield343
Dan Couper
@DanCouper
Mar 10 2017 10:58
@kaloudiyi ah, sorry, formatting threw me. What's it erroring/failing on
Aliaksandr_Pitkevich
@anfield343
Mar 10 2017 10:59
@the0ffh you are welcome
Simon Cordova
@gbsimon87
Mar 10 2017 11:19
Hey guys, I'm trying to add jQuery through a CDN to a site where jQuery is not defined. Can't seem to get it to work though, any inputs?
            var headofdoc = document.getElementsByTagName('head')[0];
            var s = document.createElement('script');
            s.setAttribute('src', 'https://code.jquery.com/jquery-3.1.1.min.js');
            s.setAttribute('integrity','sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=');
            s.setAttribute('crossorigin','anonymous');
            headofdoc.appendChild(s);
Bartosz
@CataciD
Mar 10 2017 11:21
you're setting attributes
but does it have those attributes?
cause i literally dont konw the dom by heart
and I'm not sure if you can just do it like that
because the head is read before anything is displayed
so adding anything to it shouldn't change shit unless you refresh and it stays as you changed it
change the head or somehow load jquery without using html
Simon Cordova
@gbsimon87
Mar 10 2017 11:22
I got those attributes from the actual jquery site
Bartosz
@CataciD
Mar 10 2017 11:22
i think
yeah but as I said, I think head loads first and never again
Dan Couper
@DanCouper
Mar 10 2017 11:23
Yeah, it'll just create those attributes, that's fine, second part (head is read before anything else) is the issue
AKS
@amitkumarsarangi
Mar 10 2017 11:23
hello guys... I did a project on codepen... plz have a look... and show some love...
http://codepen.io/amitkumarsarangi/full/JWWyoe/
Simon Cordova
@gbsimon87
Mar 10 2017 11:23
@amitkumarsarangi nice job
great design too
AKS
@amitkumarsarangi
Mar 10 2017 11:24
@gbsimon87 thanks bud
CamperBot
@camperbot
Mar 10 2017 11:24
:cookie: 395 | @gbsimon87 |http://www.freecodecamp.com/gbsimon87
amitkumarsarangi sends brownie points to @gbsimon87 :sparkles: :thumbsup: :sparkles:
Simon Cordova
@gbsimon87
Mar 10 2017 11:25
I like your timerfun function, it's simple and concise
AKS
@amitkumarsarangi
Mar 10 2017 11:26
@gbsimon87 show some love on codePen... :)
Dan Couper
@DanCouper
Mar 10 2017 11:27
@kaloudiyi if the property is found, you're returning contacts[i].prop which is saying look for a property literally called prop in the contact. Dot notation is only used if you know in advance what the property is called
> var prop = 'bar'
> var myObj = { foo: 1, bar: 2 }
> myObj.foo
1
> myObj.prop
undefined // there isn't a property called prop on myObj
> myObj[prop]
2
Simon Cordova
@gbsimon87
Mar 10 2017 11:28
@amitkumarsarangi I favorited it :)
AKS
@amitkumarsarangi
Mar 10 2017 11:29
@gbsimon87 cool
Simon Cordova
@gbsimon87
Mar 10 2017 11:29
@DanCouper my man what's happening! Any chance you help me out with something?
AKS
@amitkumarsarangi
Mar 10 2017 11:30
@gbsimon87 what is it... may be I can help
Simon Cordova
@gbsimon87
Mar 10 2017 11:32
            var headofdoc = document.getElementsByTagName('head')[0];
            var s = document.createElement('script');
            s.setAttribute('src', 'https://code.jquery.com/jquery-3.1.1.min.js');
            s.setAttribute('integrity','sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=');
            s.setAttribute('crossorigin','anonymous');
            headofdoc.appendChild(s);
I'm trying to add jQuery to a site which doesn't have it.
In other words, jQuery is not defined on the site.
Brandon
@ishartalot
Mar 10 2017 11:33
What defines a variable to either a global or local scope? I don't understand the difference as to what makes this or that global or local
AKS
@amitkumarsarangi
Mar 10 2017 11:34
@ishartalot if a variable is declared inside a function it cannot be accessed out of that function
Taughran23
@Taughran23
Mar 10 2017 11:34
hi guys, stuck on the free code camp profile lookup challenge. the code I've written will only return the first object in the array, none of the following ones.
Johnny
@JohnnyBizzel
Mar 10 2017 11:34
@amitkumarsarangi Very nice. Well done.
Bartosz
@CataciD
Mar 10 2017 11:34
local exists only in the scope
global exists everywhere
AKS
@amitkumarsarangi
Mar 10 2017 11:34
@JohnnyBizzel thanks bud
CamperBot
@camperbot
Mar 10 2017 11:34
amitkumarsarangi sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:star2: 1457 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
HeebieGeeBee
@HeebieGeeBee
Mar 10 2017 11:34
@gbsimon87 dont you have to create elements in capital letters?
var s = document.createElement('SCRIPT'); like that
Simon Cordova
@gbsimon87
Mar 10 2017 11:35
Not sure, I just looked it up and it appears so.
devpaaji
@devpaaji
Mar 10 2017 11:35
a = 10;
function val(){

var b = 5;
alert(b);
}
// try this in your local and let me kn
ow what you get
console.log(a);
console.log(b);
AKS
@amitkumarsarangi
Mar 10 2017 11:35
@gbsimon87 I do not know how to set attributes the way you are doing... I don't know if that is a valid thing to do... did you google it up
Johnny
@JohnnyBizzel
Mar 10 2017 11:35
@amitkumarsarangi they were talking about the importance of learning your times table at school last week. This is good for practising.
devpaaji
@devpaaji
Mar 10 2017 11:35
@ishartalot
Taughran23
@Taughran23
Mar 10 2017 11:36

function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i= 0;i <contacts.length; i++){

if(contacts[i].firstName === firstName && contacts[i].hasOwnProperty(prop)){

return contacts[i][prop];

} else if (contacts[i].firstName != firstName){
return "No such contact";

} else if (contacts[i].firstName == firstName &&  contacts[i].hasOwnProperty(prop) === false ){
  return "No such property";}

// Only change code above this line
}
}
// Change these values to test your function
lookUpProfile("Sherlock", "likes");

Bartosz
@CataciD
Mar 10 2017 11:36
hmmm @gbsimon87 shouldnt head be grabbed only once not all
Taughran23
@Taughran23
Mar 10 2017 11:36
any ideas?
Bartosz
@CataciD
Mar 10 2017 11:36
there should be one element
Taughran23
@Taughran23
Mar 10 2017 11:36
would be greatly appreciated
Brandon
@ishartalot
Mar 10 2017 11:36
@amitkumarsarangi @CataciD Okay so really the only difference is when you use "var" inside a function which makes it local as opposed to just declaring it inside the function without the var that makes it global?
Johnny
@JohnnyBizzel
Mar 10 2017 11:36
@Taughran23 everyone's favourite challenge!!
Bartosz
@CataciD
Mar 10 2017 11:36
so you can try get element by name or something like document.querySelector('head');
AKS
@amitkumarsarangi
Mar 10 2017 11:36
@JohnnyBizzel yup... now I am thinking of adding functionality for addition, subtraction and division as well
Simon Cordova
@gbsimon87
Mar 10 2017 11:37
@amitkumarsarangi that way of setting attributes is native JS
@CataciD by placing the [0] i'm telling the DOM to grab the first position of head (which technically should be the only one)
Johnny
@JohnnyBizzel
Mar 10 2017 11:37
@amitkumarsarangi I had a toy that did that. It had a few different levels.
Taughran23
@Taughran23
Mar 10 2017 11:37
thanks @JohnnyBizzel. having the best of times
CamperBot
@camperbot
Mar 10 2017 11:37
taughran23 sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:star2: 1458 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
Simon Cordova
@gbsimon87
Mar 10 2017 11:37
I think my problem lies in the fact that the code is working, but the $ is conflicting with their code
AKS
@amitkumarsarangi
Mar 10 2017 11:37
@ishartalot yup...
Johnny
@JohnnyBizzel
Mar 10 2017 11:37
@Taughran23 close but why does it fail?
Bartosz
@CataciD
Mar 10 2017 11:37
i konw what you're doing but that means you're grabbing the first element within the <head>
Simon Cordova
@gbsimon87
Mar 10 2017 11:37
I tried $.noConflict() to no avail
Bartosz
@CataciD
Mar 10 2017 11:37
you dont want to do that
you want to ADD into the head another element
HeebieGeeBee
@HeebieGeeBee
Mar 10 2017 11:37
@gbsimon87 i would also think if the page exists already wouldnt it already have a head element?
AKS
@amitkumarsarangi
Mar 10 2017 11:38
@JohnnyBizzel division is a bit tricky though...
Bartosz
@CataciD
Mar 10 2017 11:38
if a head exists then you will be having an existing element with the index 0
AKS
@amitkumarsarangi
Mar 10 2017 11:38
but I 'll see if I can get it done... @JohnnyBizzel
Simon Cordova
@gbsimon87
Mar 10 2017 11:38
There is a head tag on the page
Bartosz
@CataciD
Mar 10 2017 11:38
yes and it has elements
Simon Cordova
@gbsimon87
Mar 10 2017 11:38
so you recommend query selector?
Johnny
@JohnnyBizzel
Mar 10 2017 11:38
@amitkumarsarangi maybe start with the answer and work back to possible number pairs.
Bartosz
@CataciD
Mar 10 2017 11:38
doesnt matter which one you use
its just this
var headofdoc = document.getElementsByTagName('head')[0];
will probably pick HEAD and then the [0] element IN IT
so if you have
Taughran23
@Taughran23
Mar 10 2017 11:39
when changing the arguments to different firstNames it returns no such contact. only shows Akira when Akira is firstName argument.
AKS
@amitkumarsarangi
Mar 10 2017 11:39
@JohnnyBizzel cool... that is a good idea there
Bartosz
@CataciD
Mar 10 2017 11:39
<head>
<script/>
</head>
AKS
@amitkumarsarangi
Mar 10 2017 11:39
@JohnnyBizzel hey thanks man
CamperBot
@camperbot
Mar 10 2017 11:39
amitkumarsarangi sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
Bartosz
@CataciD
Mar 10 2017 11:39
then your thing will grab SCRIPT
CamperBot
@camperbot
Mar 10 2017 11:39
:warning: amitkumarsarangi already gave johnnybizzel points
Johnny
@JohnnyBizzel
Mar 10 2017 11:39
@amitkumarsarangi Or you could do it like 42 / ? = 7
Bartosz
@CataciD
Mar 10 2017 11:39
and will operate on it
AKS
@amitkumarsarangi
Mar 10 2017 11:40
@JohnnyBizzel yup
Johnny
@JohnnyBizzel
Mar 10 2017 11:40
@Taughran23 so your loop is probably not testing all values.
AKS
@amitkumarsarangi
Mar 10 2017 11:40
@JohnnyBizzel hey bud... if you liked my effort show some love on codepen for the project...
Johnny
@JohnnyBizzel
Mar 10 2017 11:41
@amitkumarsarangi following you now
Taughran23
@Taughran23
Mar 10 2017 11:43
cheers @JohnnyBizzel mate. so its just finding the first element in the array and stopping? is this to do with the following if statement?