These are chat archives for FreeCodeCamp/HelpJavaScript

25th
Jun 2016
darsparx
@darsparx
Jun 25 2016 00:02
@moigithub well may have figured it out...but now I feel like it needs a bunch of if's just to make sure "hidden" doesn't already exist in the classlist >_>
Peter Kenward
@PeterKenward
Jun 25 2016 00:07
I'm a bit confused: my code is working sometimes...!?! function palindrome(str) { // Good luck! var myString = str.toLowerCase(); var expression = /\s+|_+|W+/g;//This regular expression identifies spaces, underscores and non-alphanumeric characters myString = myString.replace(expression,""); var i=0; i = myString.length; var comparisonString = ""; while (i>0){ comparisonString = comparisonString+myString[i-1]; i--; } if( myString !== comparisonString){ return false; }return true; } palindrome("B a N A N a S");//Not a palindrome
Sorry that didn't work, I'll try again:
function palindrome(str) {
  // Good luck!
    var myString = str.toLowerCase();
  var expression = /\s+|_+|W+/g;//This regular expression identifies spaces, underscores and non-alphanumeric characters
  myString = myString.replace(expression,""); 
  var i=0;
  i = myString.length;
  var comparisonString = "";
  while (i>0){
    comparisonString = comparisonString+myString[i-1];
    i--;
  }
  if( myString !== comparisonString){ 
    return false;
  }return true;
  }
palindrome("B a N A N a S");//Not a palindrome
If I pass a string with character "\" the code doesn't work?
Diego Mayer
@Chrono79
Jun 25 2016 00:08
@PeterKenward your regex is wrong
Peter Kenward
@PeterKenward
Jun 25 2016 00:08
okay
Diego Mayer
@Chrono79
Jun 25 2016 00:09
W is the literal W letter
x981
@x981
Jun 25 2016 00:09
https://codepen.io/FreeCodeCamp/full/ONjoLe/ => How do i get data for this challenge?
Peter Kenward
@PeterKenward
Jun 25 2016 00:09
thanks
I'll read up again :)
Diego Mayer
@Chrono79
Jun 25 2016 00:10
@PeterKenward no problem
Peter Kenward
@PeterKenward
Jun 25 2016 00:13
So is it var expression = /\W+|_+|\s+/g; ?
Diego Mayer
@Chrono79
Jun 25 2016 00:14
@PeterKenward /\W|_/g better
a space is already a non alphanumeric char, you got it covered with \W
Peter Kenward
@PeterKenward
Jun 25 2016 00:16
I thought the + means to select every instance of whatever it is in the string rather than just the first one? Am I inventing new stuff again?
oh the space.... cool understood!
Diego Mayer
@Chrono79
Jun 25 2016 00:16
the + is a local repetition, like A+ would match A and AAAA
Peter Kenward
@PeterKenward
Jun 25 2016 00:16
oh ok
Diego Mayer
@Chrono79
Jun 25 2016 00:17
the g modifier does what you want
Peter Kenward
@PeterKenward
Jun 25 2016 00:17
And it works now! Thanks @Chrono79
CamperBot
@camperbot
Jun 25 2016 00:17
peterkenward sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1301 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jun 25 2016 00:17
@PeterKenward :+1:
Peter Kenward
@PeterKenward
Jun 25 2016 00:17
This is fun!
Matt
@TheeMattOliver
Jun 25 2016 00:17
would anybody have a look at my quote generator and tell me why my quotes aren't displaying?
PeterKenward @PeterKenward isn't there yet @TheeMattOliver :)
Diego Mayer
@Chrono79
Jun 25 2016 00:18
link?
I think it may have something to do with my button not having an anchor tag that jQuery can refer to...
Lois C L Harris
@loisishere
Jun 25 2016 00:20
I'm having trouble with Record Collection: It states in the intro "If value is blank, delete that prop", which it is deleting the prop but it still not passing
Diego Mayer
@Chrono79
Jun 25 2016 00:21
@TheeMattOliver you didn't linked jquery to start with, the cog left of js tab
add the id to the button: id="btn" and that's it
@loisishere show how are you deleting the prop
Matt
@TheeMattOliver
Jun 25 2016 00:24
d'oh
Lois C L Harris
@loisishere
Jun 25 2016 00:25

else if (value === ""){
delete collectionCopy[id][prop] = "";

}

Diego Mayer
@Chrono79
Jun 25 2016 00:25
@loisishere that's not right
review this challenge: https://www.freecodecamp.com/challenges/delete-properties-from-a-javascript-object
and you have to work with collection, not collectionCopy
Lois C L Harris
@loisishere
Jun 25 2016 00:26
sorry I ran this:

else if (value === ""){
delete collectionCopy[id][prop];

}

Matt
@TheeMattOliver
Jun 25 2016 00:27
@chrono79 I was linking to the class, not the id
gracias
Lois C L Harris
@loisishere
Jun 25 2016 00:27
I fixed it. @Chrono79 Thanks! All I needed was to switch the collections :+1:
CamperBot
@camperbot
Jun 25 2016 00:27
loisishere sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1302 | @chrono79 |http://www.freecodecamp.com/chrono79
Matt
@TheeMattOliver
Jun 25 2016 00:28
thanks @Chrono79
CamperBot
@camperbot
Jun 25 2016 00:28
theemattoliver sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1303 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jun 25 2016 00:29
@TheeMattOliver no problem, in jquery, "#someId" is an id selector, ".someClass" is a class selector and "someElement" is an element selector
so # = id, . = class and nothing, html element ;)
Matt
@TheeMattOliver
Jun 25 2016 00:30
thanks, been doing too many damn vanilla JS exercises :)
Andrew Vanboxel
@avanbox
Jun 25 2016 00:34
anyone wann give me a HINT as to why my fibonacci solution wont work
im sure its something silly
Diego Mayer
@Chrono79
Jun 25 2016 00:35
@avanbox let's see your code
Andrew Vanboxel
@avanbox
Jun 25 2016 00:36
function sumFibs(num) {
  var total = 0;
  var otherFibs = [];
  if (testForFib(num)) {
    console.log("its a fib!");
    findRemainingFibs(num);
    total = sumTheFibs(otherFibs);
  }

  function testForFib(number) {
    if (Math.sqrt((5 * (number * number) - 4)) % 1 === 0 || Math.sqrt((5 * (number * number) + 4)) % 1 === 0) {
      console.log("test passed)");
      return true;
    } else return false;

  }

  function findRemainingFibs(num) {
    console.log("in findRemaining");
    var begin = num;

    while (begin >= 0) {
      if (testForFib(begin)&&begin%2===0) {
        otherFibs.push(begin);

      }
      begin--;
    }
    return otherFibs;
  }

  function sumTheFibs(arrOfFibs) {
    var curSum;
    for (var i = 0; i < arrOfFibs.length; i++) {
      curSum += arrOfFibs[i];
    }
    return curSum;
  }
  console.log(total);
  return total;
}
sumFibs(1000);
if you see something just a small hint would be awesome.
the total usual ends up as 0.
darsparx
@darsparx
Jun 25 2016 00:38
got it to work ^_^
var home = document.getElementById("home");
            var portfolio = document.getElementById("portfolio");
            var contact = document.getElementById("contact");
            console.log(document.getElementById("home"));
            function unhidingThis(obj){ 
                if (obj.getAttribute("href") == "#home"){
                    home.classList.remove("hidden");
                    portfolio.classList.add("hidden");
                    contact.classList.add("hidden");
                }else if (obj.getAttribute("href") == "#portfolio"){
                    home.classList.add("hidden");
                    portfolio.classList.remove("hidden");
                    contact.classList.add("hidden");
                }else if (obj.getAttribute("href") == "#contact"){
                    home.classList.add("hidden");
                    portfolio.classList.add("hidden");
                    contact.classList.remove("hidden");
                }
                return false;
            }
Diego Mayer
@Chrono79
Jun 25 2016 00:38
@avanbox do you know what is the definition of a fibonacci number?
Peter Weinberg
@no-stack-dub-sack
Jun 25 2016 00:39
@GregatGit Ahhhhhh... this def works, thanks. Maybe I should've been using jQuery inside of the setInterval function, still can't quite figure out why mine didn't work. I guess because I didn't assign it to a var? Oh, well. I'll play around some more and make sure I understand it. I like what you did with incrementing the seconds and setting the interval for only 1 second.
CamperBot
@camperbot
Jun 25 2016 00:39
no-stack-dub-sack sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:cookie: 620 | @gregatgit |http://www.freecodecamp.com/gregatgit
Andrew Vanboxel
@avanbox
Jun 25 2016 00:40
isnt it if (Math.sqrt((5 (number number) - 4)) % 1 === 0 || Math.sqrt((5 (number number) + 4)) % 1 === 0)
Diego Mayer
@Chrono79
Jun 25 2016 00:42
@avanbox never seen it tested like that, but you have to generate all the fibonacci numbers <= num and sum the odd ones
Brad Rumack
@brumack
Jun 25 2016 00:47
hey guys! I'd greatly appreciate some help if possible. I'm having trouble with the filter method. Particular the Destroyer lesson. I'm able to break down the arguments into the initial array to filter, and then the array of filter values, but beyond that I'm totally stumped. No idea how to filter an array with another array of values
Nicolas Reboredo
@nicolasmdf
Jun 25 2016 00:48
Hey guys, how are you all doing?
I have a question about Mutations, could I maybe get some feedback?
Diego Mayer
@Chrono79
Jun 25 2016 00:49
@avanbox if the number is not a fibonacci number you return 0, that's not right
and still don't know why but sometimes your functions return NaN (this is because curSum is undefined, set it as 0 when you declare it)
@brumack try using a loop and change the value you use in the filter that way
@nicolasmdf ask
Brad Rumack
@brumack
Jun 25 2016 00:52
@Chrono79 ok cool yeah that's kinda what I was thinking. glad to have someone confirm that. thanks
CamperBot
@camperbot
Jun 25 2016 00:52
brumack sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1304 | @chrono79 |http://www.freecodecamp.com/chrono79
Nicolas Reboredo
@nicolasmdf
Jun 25 2016 00:52
I know there is a better, shorter solution to this, but I cant find it, but as far as I can see this solution should work:
function mutation(arr) {
    var values = [];
    arr[0] = arr[0].toLowerCase();
    arr[1] = arr[1].toLowerCase();
for (var i = 0; i < arr[1].length; i++) {
     values.push(arr[0].indexOf(arr[1][i]));
}
for (var valuesIndex = 0; valuesIndex < values.length; valuesIndex++) {
    if (values[valuesIndex] < 0) {
        return false;
    } else {
        return true;
    }
}
}
it passes all the tests except for the first one
Diego Mayer
@Chrono79
Jun 25 2016 00:54
@nicolasmdf don't return true inside the loop, that way (returning inside) if the first letter of the second word is in the first, you return true and exit the loop
Vinicius Costa
@viniciuscosta89
Jun 25 2016 00:55
Hi everybody. I'm stuck at "Record Collection" challenge.
Left just one objective After updateRecords(5439, "tracks", "Take a Chance on Me"), tracks should have "Take a Chance on Me" as the last element.
Nicolas Reboredo
@nicolasmdf
Jun 25 2016 00:55
it worked, of course! I will chew on that before taking on the next one :smile: Thanks a lot @Chrono79 !
CamperBot
@camperbot
Jun 25 2016 00:55
nicolasmdf sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1305 | @chrono79 |http://www.freecodecamp.com/chrono79
Vinicius Costa
@viniciuscosta89
Jun 25 2016 00:55

My code: function updateRecords(id, prop, value) {
if (value === '') {
delete collection[id][prop];
} else if (prop !== 'tracks') {
collection[id][prop] = value;
} else {
collection[id][prop].push(value);
}

return collection;
}

Diego Mayer
@Chrono79
Jun 25 2016 00:56
@viniciuscosta89 before pushing, you have to check if tracks is there
https://www.freecodecamp.com/challenges/testing-objects-for-properties
Vinicius Costa
@viniciuscosta89
Jun 25 2016 00:59
@Chrono79 Ok. I'll check this
@Chrono79 Thanks!
CamperBot
@camperbot
Jun 25 2016 00:59
viniciuscosta89 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1306 | @chrono79 |http://www.freecodecamp.com/chrono79
Chris Santoso
@csantoso
Jun 25 2016 01:12
@nicolasmdf Another solution is to have your program return true by default, and using a for loop, loop through and check the letters of the second array, using indexOf, and if str.indexOf < 0 for any of the values, then immediately return false
Peter Weinberg
@no-stack-dub-sack
Jun 25 2016 01:14
@GregatGit well obviously a little late on this but if you do happen to see it, that actually wasn't the solution, but thanks for your input, it helped me get here. Your code appeared to work because of the second++, but really that was just an illusion, and if you let it go, it would count up, past 60, forever. if the code was really running every second, there would be no need to increment the seconds because they would automatically going up. Anyway, it turned out to be a scope issue. I was not declaring the vars or calling the new Date within the interval. Fix is here:
// clock vars & functions
  var myTime = setInterval(function(){
    var time = new Date();
    var clockHr = time.getHours();
    var clockMin = time.getMinutes();
    var seconds = time.getSeconds();
    var suffix = "";
    var aOrP = "";
    hourCorrect(hour);
    minCorrect(clockMin);
    secCorrect(seconds);
    showTime();

    function hourCorrect(num) {
      if (num > 12) {
         clockHr = (clockHr - 12)
        aOrP = "PM"
      } else if (num === 0) {
          clockHr = 1;
          aOrP = "AM";
      } else {
          clockHr = clockHr
          aOrP = "AM"
          }
        }

    function minCorrect(num) {
      if (num < 10) {
        return clockMin = "0" + clockMin;
      }
    }

    function secCorrect(num) {
      if (num < 10) {
        return seconds = "0" + seconds;
      }
    }

    function showTime() {
      document.getElementById("clockTime").innerHTML = (clockHr + ":" + clockMin + ":" + seconds + " " + aOrP);
    }
  }, 1000); // end clock functions
CamperBot
@camperbot
Jun 25 2016 01:14
no-stack-dub-sack sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:warning: no-stack-dub-sack already gave gregatgit points
Kevin Murphy
@kaym0
Jun 25 2016 01:43
Hey.
Question! When using altering arrays using things like .replace() what does (/[\W_]/g, mean?
I'm looking at some code, and I've looked at a few tables. I can't seem to find anything identifying what that means.
Kevin Murphy
@kaym0
Jun 25 2016 01:53
For example, str.replace(/[W_]/g, '');
I know it's essentially replacing parts of the string, but I'm trying ot figure out what the codes mean. Like /[W_]/g
Diego Mayer
@Chrono79
Jun 25 2016 01:54
@kaym0 that's a regex to replace non alphanumeric chars for nothing (it deletes them)
Kevin Murphy
@kaym0
Jun 25 2016 01:54
What? g or W?
or the entire thing
IS ther somewhere I can read about that in specific?
Diego Mayer
@Chrono79
Jun 25 2016 01:54
you forgot the \
help regex
CamperBot
@camperbot
Jun 25 2016 01:54

:point_right: js regex resources [wiki]

Regular Expressions Resources

Links to useful RegEx resources.

See also: :clipboard: Tutorials | :syringe: Testing | :soccer: Games | :newspaper: Blogs | :package: Software

:pencil: read more about js regex resources on the FCC Wiki

Kevin Murphy
@kaym0
Jun 25 2016 01:54
It deletes it here
In the chat
Automatically
Diego Mayer
@Chrono79
Jun 25 2016 01:55
use backticks
help format
CamperBot
@camperbot
Jun 25 2016 01:55

:point_right: code formatting [wiki]

Multi line Code

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

Single line Code

This an inline `<paste code here>` code formatting with a single backtick() at _start_ and _end_ around thecode`.

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

Kevin Murphy
@kaym0
Jun 25 2016 01:55
Thanks, Diego
Thanks, Chrono79
Diego Mayer
@Chrono79
Jun 25 2016 01:55
no problem
Kevin Murphy
@kaym0
Jun 25 2016 01:55
Thanks @Chrono79
CamperBot
@camperbot
Jun 25 2016 01:55
:star2: 1307 | @chrono79 |http://www.freecodecamp.com/chrono79
kaym0 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
Kevin Murphy
@kaym0
Jun 25 2016 01:55
help regex
CamperBot
@camperbot
Jun 25 2016 01:55

:point_right: js regex resources [wiki]

Regular Expressions Resources

Links to useful RegEx resources.

See also: :clipboard: Tutorials | :syringe: Testing | :soccer: Games | :newspaper: Blogs | :package: Software

:pencil: read more about js regex resources on the FCC Wiki

friesenet21
@friesenet21
Jun 25 2016 02:14
    ```js

function chunkArrayInGroups(arr, size) {
// Break it up.
var newArr = []; //sets up 2 dimentional array
for (var i = 0; i <= arr.length; i++) { //loops forward through arr
arr[i] = arr.slice(0, size); // slices size of arr from beginning of array
newArr.push(arr[i]); // pushes the slice into the new 2D array
arr = arr.slice(size); // cuts the old "arr" and sends it "for" the loop
}
return newArr;
}

chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 5);
```

```js function chunkArrayInGroups(arr, size) {
// Break it up.
var newArr = []; //sets up 2 dimentional array
for (var i = 0; i <= arr.length; i++) { //loops forward through arr
arr[i] = arr.slice(0, size); // slices size of arr from beginning of array
newArr.push(arr[i]); // pushes the slice into the new 2D array
arr = arr.slice(size); // cuts the old "arr" and sends it "for" the loop
}
return newArr;
}

chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 5);
```

function chunkArrayInGroups(arr, size) {
  // Break it up.
  var newArr = []; //sets up 2 dimentional array
  for (var i = 0; i <= arr.length; i++) { //loops forward through arr
    arr[i] = arr.slice(0, size); // slices size of arr from beginning of array
    newArr.push(arr[i]); // pushes the slice into the new 2D array 
    arr = arr.slice(size); // cuts the old "arr" and sends it "for" the loop
  }
  return newArr;
}
chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 5);
I have a situation.
function chunkArrayInGroups(arr, size) {
  // Break it up.
  var newArr = []; //sets up 2 dimentional array
  for (var i = 0; i <= arr.length; i++) { //loops forward through arr
    arr[i] = arr.slice(0, size); // slices size of arr from beginning of array
    newArr.push(arr[i]); // pushes the slice into the new 2D array 
    arr = arr.slice(size); // cuts the old "arr" and sends it "for" the loop
  }
  return newArr;
}

chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 5);
friesenet21
@friesenet21
Jun 25 2016 02:22
This is Chunky Monkey. I am trying to return less than 2 numbers in the sub array
Is anyone available to help please...
Tarif
@TarifChandan
Jun 25 2016 02:27
Hi..
Should I start with books to learn javascript?
ALMY91
@ALMY91
Jun 25 2016 02:34


//Return the sum of the elements of array a(or array-like objects)
//The elements of array a must be all numbers or null and undefined are ignored.  
function sum(a) {
if (isArrayLike(a)){
var total =0;
for(var i=0; i<a.length; i++){ //Loop through all elements
var element=a[i];
if (element == null) continue; //Skip null and undefined
if (isFinite(element)) total+=element;
else throw new Error("sum(): elements must be finite numbers");
}
return total;

}
else throw new Error("sum(): argument must be array-like");
}

var isArrayLike;
console.log(sum([1,2,3,4,5]));
friesenet21
@friesenet21
Jun 25 2016 02:34
I have not been reading any programming books, but I may start soon though given that my laptop only works in, you know, very indirect sunlight.
ALMY91
@ALMY91
Jun 25 2016 02:34
Hello can anybody help me out my code ain working
Tarif
@TarifChandan
Jun 25 2016 02:36
@friesenet21 How have you been learning Javascript?
Diego Mayer
@Chrono79
Jun 25 2016 02:36
@friesenet21 using a for loop and modifying the array you iterate over doesn't seem a very good idea
friesenet21
@friesenet21
Jun 25 2016 02:38
is a while loop better, or can i modify the arr first?
@Chrono79
Diego Mayer
@Chrono79
Jun 25 2016 02:40
@friesenet21 you could use a while loop and splice instead of slice, or a for loop and slice but changing the begin and end each loop
Carlos Zavaleta
@nerdyamigo
Jun 25 2016 02:45
could someone help me with one of the algorithms please?
im on the chunky Monkey challenge
martinronquillo
@martinronquillo
Jun 25 2016 02:46

// Setup
var testObj = {
"an entree": "hamburger",
"my side": "veggies",
"the drink": "water"
};

// Only change code below this line

entreeValue["hamburger"]; // Change this line
drinkValue["water"]; // Change this line
Accessing Objects Properties with Bracket Notation

im stuck on this excersize
Nahid
@nahid-uddin
Jun 25 2016 02:50
How hard isit to learn javascript?
Carlos Zavaleta
@nerdyamigo
Jun 25 2016 02:50
@martinronquillo you have to access the object using bracket notation
to get to hamburger you's use
testObj['an entree'];
@martinronquillo and that will get you to where you need to go and same with the 'veggies' and 'water'
@martinronquillo you access them with bracket notation because the keys have spaces in them so using dot notation is not an option
martinronquillo
@martinronquillo
Jun 25 2016 02:53
when I put this in the compiler it gives me a ReferenceError: entreeValue is not defined
@cyberamigo
Diego Mayer
@Chrono79
Jun 25 2016 02:53
@cyberamigo :point_up: 24 de junio de 2016 23:40 that's an advice for chunky monkey
Carlos Zavaleta
@nerdyamigo
Jun 25 2016 02:53
@martinronquillo thats because that is not what the value is called, look at the testObj object
@Chrono79 I got it! i used slice like you said, but i still kept the for loop
@martinronquillo you should use
testObj['an entree'];
@martinronquillo to access the hamburger value
@nahid-uddin every language has its obstacles, javascript is no different, if you have experience with other languages you';ll surprised how different javascript is
martinronquillo
@martinronquillo
Jun 25 2016 02:57
@cyberamigo i cant see to wrap my head around this all that well
Nahid
@nahid-uddin
Jun 25 2016 02:58
Thanks @cyberamigo
CamperBot
@camperbot
Jun 25 2016 02:58
nahid-uddin sends brownie points to @cyberamigo :sparkles: :thumbsup: :sparkles:
:cookie: 169 | @cyberamigo |http://www.freecodecamp.com/cyberamigo
Nahid
@nahid-uddin
Jun 25 2016 02:59
I landed an internship, for a webmaster role. The role requires html and css which I am fluent. It also said some javascript would be useful but not essential. I'm assuming they'll teach me in the role. However I would like to impress them with my knowledge. What would you recommend to learn? @cyberamigo
Sorry let me paraphrase, for Web development what would you specifically learn for javascript @cyberamigo
Michaelangelo Leon
@mikey1995
Jun 25 2016 03:01

in the code used to randomly generate a number between a max and min range why do you need the +1?

code:
Math.floor(Math.random() * (max - min + 1)) + min

Carlos Zavaleta
@nerdyamigo
Jun 25 2016 03:02
@martinronquillo alright, you want to access the value stored in a specific key from an object in javaScript an object holds values and keys like this
var carObj = {
'car maker' : 'Chevy',      
'year' : 2006,
'make or model' : 'avalanche'
}

//to access the car maker i have to acees the object and pull that value out
carObj['car maker']; //this accesses that value stored in the car maker key
@nahid-uddin I would start by learning the very basics, here you can do the jquery challenges and the javascript challenges which are really good place to start, I would focus on the core principles of javascript, i used this when i started:
martinronquillo
@martinronquillo
Jun 25 2016 03:04

@cyberamigo
// Setup
var testObj = {
"an entree": "hamburger",
"my side": "veggies",
"the drink": "water"
};

// Only change code below this line

testObj['an entree']; // Change this line
testObj['the drink']; // Change this line

this is what i came up with
Carlos Zavaleta
@nerdyamigo
Jun 25 2016 03:05
@mikey1995 if im not mistaken is so that the max is included
@martinronquillo you got it
martinronquillo
@martinronquillo
Jun 25 2016 03:05
@cyberamigo
Carlos Zavaleta
@nerdyamigo
Jun 25 2016 03:05
@martinronquillo that will give you access to those values
:+1:
martinronquillo
@martinronquillo
Jun 25 2016 03:05
thats the thing its not working
ALMY91
@ALMY91
Jun 25 2016 03:06
Hi is anybody able to help me out?
Carlos Zavaleta
@nerdyamigo
Jun 25 2016 03:06
it works on my side, you only need to access the values for the challenge?
@martinronquillo what is the name of the challenege?
Nahid
@nahid-uddin
Jun 25 2016 03:06
Thanks @cyberamigo
CamperBot
@camperbot
Jun 25 2016 03:06
nahid-uddin sends brownie points to @cyberamigo :sparkles: :thumbsup: :sparkles:
:warning: nahid-uddin already gave cyberamigo points
Carlos Zavaleta
@nerdyamigo
Jun 25 2016 03:06
@nahid-uddin :+1:
martinronquillo
@martinronquillo
Jun 25 2016 03:07
@cyberamigo ReferenceError: entreeValue is not defined
i get this
Robin Cruz
@robinkd6
Jun 25 2016 03:08

My palindrome @PeterKenward
function isPalindrome(str) {
if (str.length === 0) {
return true; //str.length is not 0 --> bypass the block
}
if (str[0] !== str[str.length - 1]) { //if str index is not
return false;
}
return isPalindrome(str.slice(1, str.length-1));
}

console.log(isPalindrome("otto")); //pass through --> truncating the word

Carlos Zavaleta
@nerdyamigo
Jun 25 2016 03:08
@martinronquillo what is the name for the challenge?
martinronquillo
@martinronquillo
Jun 25 2016 03:08
Accessing Objects Properties with Bracket Notation
Carlos Zavaleta
@nerdyamigo
Jun 25 2016 03:09
@martinronquillo

// Setup
var testObj = {
  "an entree": "hamburger",
  "my side": "veggies",
  "the drink": "water"
};

// Only change code below this line

var entreeValue = testObj['an entree'];   // Change this line
var drinkValue = testObj['the drink'];    // Change this line
@martinronquillo I just tried it and it passed
@robinkd6 Oh man i had to hack my way out of that one lol
Diego Mayer
@Chrono79
Jun 25 2016 03:10
@robinkd6 you still need to clean the string and also level it (that is, either lowercase or uppercase it)
Carlos Zavaleta
@nerdyamigo
Jun 25 2016 03:11
@robinkd6 I used a reg expression to clean up the screen, get rid off spaces and special chars
martinronquillo
@martinronquillo
Jun 25 2016 03:11
@cyberamigo I really appreciate the help. You went out of your way to hit me with some examples so i can understand the concept. Thank You!
CamperBot
@camperbot
Jun 25 2016 03:11
martinronquillo sends brownie points to @cyberamigo :sparkles: :thumbsup: :sparkles:
:cookie: 170 | @cyberamigo |http://www.freecodecamp.com/cyberamigo
Carlos Zavaleta
@nerdyamigo
Jun 25 2016 03:12
@martinronquillo did it work? it might be a bug, or maybe you just have to refresh the page, no problem. I know what it feels like not understanding something man
martinronquillo
@martinronquillo
Jun 25 2016 03:13
@cyberamigo Yea it worked Im already strollin through these other lessons haha
Carlos Zavaleta
@nerdyamigo
Jun 25 2016 03:13
@martinronquillo there ya go, yea whenever you have a key with weird characters you'll need to use bracket notation if its just a single string you can use dot notation :D
Just need 5 more algorithms and im through with those ayeeee
Duncan T
@dtweedle
Jun 25 2016 03:18
Anyone here able to step me through some Psuedo on the Sorted Union algorithm? I sold it before using some ugly loop but I'm trying to figure out the best way to use .reduce to get the answer..
*solved
ALMY91
@ALMY91
Jun 25 2016 03:20
is anybody out there?
:(
Duncan T
@dtweedle
Jun 25 2016 03:20
*tumbleweeds blows past.
ALMY91
@ALMY91
Jun 25 2016 03:22
Hello :3
is anybody here :3
@Isymm HAHAHAHA
Duncan T
@dtweedle
Jun 25 2016 03:24
Yeah.. no one here to help us out :worried:
ALMY91
@ALMY91
Jun 25 2016 03:25
@Isymm TUMBLEWEED :3 i learnt smth new today
@Isymm :D
silver537
@silver537
Jun 25 2016 03:25
You gotta wait til there is an avid programmer.
Duncan T
@dtweedle
Jun 25 2016 03:26
Waiting is not my strong point.. :/
ALMY91
@ALMY91
Jun 25 2016 03:26
@Isymm lets chat while waiting for the seniors :3
@Isymm do you like kristen stewart
@Isymm HAHAHAH
silver537
@silver537
Jun 25 2016 03:27
One of the virtuous requirements for programming is patience. Cmon man.
ALMY91
@ALMY91
Jun 25 2016 03:30
i wanna shit but i cant
im in a public library and i have anxiety pooping in public loos
*tumbleweed blows past
ALMY91
@ALMY91
Jun 25 2016 03:35
HEEEEELPPPPPP
silver537
@silver537
Jun 25 2016 03:36
You can shit anywhere. Just dont get caught
ALMY91
@ALMY91
Jun 25 2016 03:37
we are not in china
lol
im wondering if i shd check in a hotel to do work
zzzz
silver537
@silver537
Jun 25 2016 03:40
Lmao. What? Why
Just take a shit dude. Dont be such a girl
ALMY91
@ALMY91
Jun 25 2016 03:40
to poop and to laze on the bed while waiting
silver537
@silver537
Jun 25 2016 03:45
You have an irrational mind.... idk if thats a good thing or not. Especially for programming.
ALMY91
@ALMY91
Jun 25 2016 03:46
You need to be a little insane to do great things :3
Greg Duncan
@GregatGit
Jun 25 2016 03:48
@no-stack-dub-sack I'm glad you got it working. My key point was using a setInterval with as a variable (something to use for the pomodoro clock). Your code tho needs a bit more consideration. I was under the impression that you want it to look up the weather every 5 minutes or whatever you want. But every second you will be creating a new variable var time = new Date(); a some other calls when you already have them. When the majority of them time all you need do is incremment the seconds and show it. When you have lots of functions firing off when you don't have to - you need to rethink the process
clintonjohn
@clintonjohn
Jun 25 2016 03:49

// Example
function ourFunction(isItTrue) {
if (isItTrue) {
return "Yes, that was true";
}
return "No, that was false";
}

// Setup
function trueOrFalse(wasThatTrue) {

// Only change code below this line.
if (wasThatTrue){
return "Yes, that was true";
}
return "No, that was not true";

// Only change code above this line.

}

// Change this value to test
trueOrFalse(true);

It says trueOrFalse(false) should return "No, that was false"
silver537
@silver537
Jun 25 2016 04:00
Too much insanity!!
Catherine Kim
@Catherinesjkim
Jun 25 2016 04:04
Hi! I need help with Return Early Pattern for Functions

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

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

// Only change code above this line

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

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

ALMY91
@ALMY91
Jun 25 2016 04:07
hello...
Catherine Kim
@Catherinesjkim
Jun 25 2016 04:07
Please help!
E-Tank
@E-Tank
Jun 25 2016 04:08
help return early pattern
CamperBot
@camperbot
Jun 25 2016 04:08

:point_right: challenge return early pattern for functions [wiki]

Challenge Return Early Pattern for Functions

When a return statement is reached, the execution of the current function stops and control returns to the calling location.

:pencil: read more about challenge return early pattern for functions on the FCC Wiki

E-Tank
@E-Tank
Jun 25 2016 04:09
What's the goal of the challenge? It's been a while.
silver537
@silver537
Jun 25 2016 04:15
Almy have you taken your shit yet.
ALMY91
@ALMY91
Jun 25 2016 04:15
@silver537 No hahahaha
@silver537 i was watching TheYoungTurks
silver537
@silver537
Jun 25 2016 04:15
Lol, trying to distract your ass from letting everything out?
Carl P.
@alofacarl
Jun 25 2016 04:17
@Catherinesjkim you have an extra ";" somewhere
Norvin Burrus
@ndburrus
Jun 25 2016 04:28
@clintonjohn Which exercise (name) is this?
Carlos Zavaleta
@nerdyamigo
Jun 25 2016 04:29
help mutations
CamperBot
@camperbot
Jun 25 2016 04:29

:point_right: algorithm mutations [wiki]

Algorithm Mutations

:triangular_flag_on_post: Remember to use Read-Search-Ask if you get stuck. Try to pair program :busts_in_silhouette: and write your own code :pencil:

:checkered_flag: Problem Explanation:

  • Return true if the string in the first element of the array contains all of the letters of the string in the second element of the array..

Relevant Links

:pencil: read more about algorithm mutations on the FCC Wiki

silver537
@silver537
Jun 25 2016 04:29
@ALMY91 take a shit!
Carlos Zavaleta
@nerdyamigo
Jun 25 2016 04:29
can someone help me with this please, i don't know what I need to do
Mike Olo
@michaelolo24
Jun 25 2016 04:31
help symmetric difference
CamperBot
@camperbot
Jun 25 2016 04:31

:point_right: algorithm symmetric difference [wiki]

Algorithm Symmetric Difference

Problem Explanation:

Symmetric Difference is the difference between two sets.

So in the Symmetric Difference Algorithm you would work through the arrays of numbers something like this -

sym(A, B, C) Translates to sym(sym(A,B),C)

Or in plain English - First find the Symmetric Difference of Set A and Set B. Then find the Symmetric Difference of this new set and Set C.

So -

sym([1, 2, 5], [2, 3, 5], [3, 4, 5])

would equal

[1,4,5]

:pencil: read more about algorithm symmetric difference on the FCC Wiki

Aggrovirus
@Aggrovirus
Jun 25 2016 04:35
I am stuck guys

// Declarations
var StUdLyCapVaR;
var properCamelCase;
var TitleCaseOver;

// Assignments
STUDLYCAPVAR = 10;
PRoperCAmelCAse = "A String";
tITLEcASEoVER = 9000;

i don't know what it want me to do
studlyCapVar is defined and has a value of 10
properCamelCase is defined and has a value of "A String"
titleCaseOver is defined and has a value of 9000
studlyCapVar should use camelCase in both declaration and assignment sections.
properCamelCase should use camelCase in both declaration and assignment sections.
titleCaseOver should use camelCase in both declaration and assignment sections.
this is error messages
silver537
@silver537
Jun 25 2016 04:37
Look up what camel case means in programming.
Aggrovirus
@Aggrovirus
Jun 25 2016 04:38
yep i saw but i dont get it
shahutsav
@shahutsav
Jun 25 2016 04:38
Hey guys, can someone help me with this? I want to create an inner div after every 4 images
if(hold[0]!=null){
var imgDiv = document.createElement('div');
imgDiv.setAttribute('id','imageDiv');
document.getElementsByTagName('body')[0].appendChild(imgDiv);
    for(var i=1; i<17;i++){
        var imgEle = document.createElement('img');
        imgEle.setAttribute('src',hold[0]+'copa'+i+'.jpg');
        imgEle.setAttribute('width','64px');
        imgEle.setAttribute('height','64px');
        imgDiv.appendChild(imgEle);
    }
How do I run another loop inside that creates a div for every 4 images?
silver537
@silver537
Jun 25 2016 04:39
Are each of those words in camel case?
I+=4
Aggrovirus
@Aggrovirus
Jun 25 2016 04:40
I have transformed the word from StUdLyCapVaR to StUdLyCapVaRcamelCase but it doesn't work
silver537
@silver537
Jun 25 2016 04:40
Noooo camel case is a concept.
shahutsav
@shahutsav
Jun 25 2016 04:41
@silver537 that only creates the first 4 images. Not the others
silver537
@silver537
Jun 25 2016 04:41
Use a differe iteration. And put +=4
shahutsav
@shahutsav
Jun 25 2016 04:41
@silver537 I am trying to dynamically create a div for every 4 images out of 16 images.
silver537
@silver537
Jun 25 2016 04:42
Oh
shahutsav
@shahutsav
Jun 25 2016 04:43
So my code would have an outer div then 4 divs inside, each with 4 images. :/
silver537
@silver537
Jun 25 2016 04:45
2d loop. The outer one creates the divs. And the inner inputs the images
shahutsav
@shahutsav
Jun 25 2016 04:45
So my outer loop would loop through 1-4?
*1-5 rather.
And the inner one 16times?
silver537
@silver537
Jun 25 2016 04:46
@Aggrovirus thisIsCamelCaseWhereTheFirstLetterOfFirstWordIsLowercaseAndTheRestOfTheLettersAreCapiralized.
The inner loop with be 4 as well. 4*4 is 16. Just gotta find a way to make the new loop start at 5. And the third loop start at 9. An so forth
ALMY91
@ALMY91
Jun 25 2016 04:54
Hello is anybody able to help me out here?
Catalin Scripcariu
@CatalinScr
Jun 25 2016 04:56
@ALMY91 what is the problem...?
silver537
@silver537
Jun 25 2016 04:56
@ALMY91 no. Get outtahere
:3
CamperBot
@camperbot
Jun 25 2016 04:56

:point_right: install django flask [wiki]

Setting Up Python Web-framework Django and Flask

Previous

Home

In this article, we shall be discussing how to install Django and Flask - two popular web frameworks written in Python.

Perhaps you are already familiar with the widespread usage and community support for Python; in web-development. You might as well be aware as to what a web framework is; and the options available for Python.

In case these assumptions are untrue, you might want to take a look at this wiki article. If you are all caught up, let's go ahread with setting up Python web frameworks in your local development machine.

But it would be unfair if we completely ignore the Python 2 vs Python 3 debate.

:pencil: read more about install django flask on the FCC Wiki

Ben Hogoboom
@bjhogoboom
Jun 25 2016 04:59
Hey everyone, I just spent a while on the profile lookup. I was wondering if there is some concrete difference to decide when to use dot and when to use bracket notation, as sometimes one works and not the other.
ALMY91
@ALMY91
Jun 25 2016 04:59
@silver537 HAHAHAHAH :3
@CatalinScr Im having some problems here with my code its not working

//Return the sum of the elements of array a(or array-like objects)
//The elements of array a must be all numbers or null and undefined are ignored.  
function sum(a) {
if (isArrayLike(a)){
var total =0;
for(var i=0; i<a.length; i++){ //Loop through all elements
var element=a[i];
if (element == null) continue; //Skip null and undefined
if (isFinite(element)) total+=element;
else throw new Error("sum(): elements must be finite numbers");
}
return total;

}
else throw new Error("sum(): argument must be array-like");
}

var isArrayLike(a);
console.log(sum([1,2,3,4,5]));
silver537
@silver537
Jun 25 2016 05:01
Whats that sorcery
ALMY91
@ALMY91
Jun 25 2016 05:01
@CatalinScr Uncaught SyntaxError: Unexpected token (
Catalin Scripcariu
@CatalinScr
Jun 25 2016 05:03
isArrayLike(a) is undefined
Alando
@Landoghini
Jun 25 2016 05:05
Im currently stuck on the Escaping Literal Quotes in Strings section in FCC, and Ive tried rearranging my string multiple time to no avail
Can anyone help?
Krishna Sai Gullapalli
@Krish2704
Jun 25 2016 05:06
@Landoghini show me what you've tried
Ben Hogoboom
@bjhogoboom
Jun 25 2016 05:06
@Landoghini I just did that yesterday, what's up?
Shusil Banjade
@shusil123
Jun 25 2016 05:07
@bjhogoboom , when you have to access a property with a variable, you have to use bracket notation. When the property is known , dot notation is preferred. When the property has a space in it , bracket notation is preferred. myObj.name; , myObj["first name"] , myObj[checkProp], where checkProp is a variable, which may be equal to any property already assigned or passed via function argument.
Ben Hogoboom
@bjhogoboom
Jun 25 2016 05:08
I see, so dot notation assumes that what follows is the name of the property
not something that evaluates to it
Shusil Banjade
@shusil123
Jun 25 2016 05:09
Yes, @bjhogoboom
Ben Hogoboom
@bjhogoboom
Jun 25 2016 05:10
so if firstName = "tim", contacts[firstName] isn't the same as contacts.firstName because contacts.firstName is the same as contacts["firstName"]
ALMY91
@ALMY91
Jun 25 2016 05:10
@CatalinScr Hi :(
Catalin Scripcariu
@CatalinScr
Jun 25 2016 05:11
@ALMY91 I started I private chat we can speack there
Ben Hogoboom
@bjhogoboom
Jun 25 2016 05:13
Thanks @shusil123 !
CamperBot
@camperbot
Jun 25 2016 05:13
bjhogoboom sends brownie points to @shusil123 :sparkles: :thumbsup: :sparkles:
:cookie: 526 | @shusil123 |http://www.freecodecamp.com/shusil123
allenewood
@allenewood
Jun 25 2016 05:24
Can anyone help with "Get Geo-Location Data"? It's saying that I need to display the users' position within the data div :
script>
  // Only change code below this line.

  if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function(position) {
      $("data").html("latitude: " + position.coords.latitude + "<br>longitude: " + position.coords.longitude);
    });
  }

  // Only change code above this line.
</script>
<div id = "data">
  <h4>You are here:</h4>

</div>
Shusil Banjade
@shusil123
Jun 25 2016 05:26
@bjhogoboom , yes , You got it right . Perfect. :+1:
Alex T.
@lx-t
Jun 25 2016 05:28
@allenewood With $("data") jQuery selector you're trying to select data tag. There's no such tag in HTML. You need to select element with data id.
allenewood
@allenewood
Jun 25 2016 05:30
Select the H4?
Anon3333
@Anon3333
Jun 25 2016 05:31
I need help on javascript lesson: Record Collection. I just don't know what they want me to do.
Carlos Zavaleta
@nerdyamigo
Jun 25 2016 05:31
@allenewood i just started jquery so i might be mistaken but should it not be "#data"
@Anon3333 what you got right now?
Anon3333
@Anon3333
Jun 25 2016 05:32
@cyberamigo Nothing lol.
Carlos Zavaleta
@nerdyamigo
Jun 25 2016 05:33
help Record Collection
CamperBot
@camperbot
Jun 25 2016 05:33

:point_right: challenge record collection [wiki]

Challenge Record Collection

:triangular_flag_on_post: Remember to use Read-Search-Ask if you get stuck. Try to pair program :busts_in_silhouette: and write your own code :pencil:

:checkered_flag: Problem Explanation:

You are given a JSON object representing (a small part of) your record collection. Each album is identified by a unique id number and has several properties. Not all albums have complete information.

Write a function which takes an id, a property (prop), and a value.

For the given id in collection:

If value is non-blank (value !== ""), then update or set the value for the prop.

If the prop is "tracks" and value is non-blank, check to see if the given element in the array has the property of "tracks". If the element has the property of "tracks", push the value onto the end of the "tracks" array. If the element does not have the property, create the property and value pair.

If value is blank, delete that prop.

Always return the entire collection object.

:pencil: read more about challenge record collection on the FCC Wiki

allenewood
@allenewood
Jun 25 2016 05:33
@cyberamigo Thanks, got it!
CamperBot
@camperbot
Jun 25 2016 05:33
allenewood sends brownie points to @cyberamigo :sparkles: :thumbsup: :sparkles:
:cookie: 185 | @cyberamigo |http://www.freecodecamp.com/cyberamigo
Carlos Zavaleta
@nerdyamigo
Jun 25 2016 05:34
:D if you need a deeper explanation let me know
:+1:
Claudio Restifo
@Marmiz
Jun 25 2016 05:35
Hello guys, I am in very need of some help; I'm so tilted right now.
I am developing my Tic Tac toe game, so far I'm implementing it as a 2 player version to see if everything works. (AI later).
Everything seems to work except the reset button.
Somehow after clicking it, every single move will trigger the ' X Won' function.
any ideas?
here's the link to the project where you can see the whole JS.
thanks a lot!
http://codepen.io/Marmiz/pen/qNazRr?editors=0110
Omar
@theomar3
Jun 25 2016 05:39

I have a question regarding a basic JS challenge from Javascript for Kids.
"A movie theater wants to use JS to see if a kid is allowed to see a PG-13 movie or not. If someone is over 13, they're allowed in. If younger than 13, they must be accompanied by an adult to be allowed in. Otherwise, they can't get in."

So far I have this:
var age = 12;
var adult = true;
var allowed = (age >= 13) || ((age <=12) && adult);

allowed;
true;

However, when I do this:
age = 6;
adult = false;
allowed;
true;

I still get true, but it should be false. How do I fix this? I hope that wasn't too confusing - my first time posting a question on here. Thanks!

I think the problem is stemming from the
var adult = true; and how I've implemented it into the code but I can't figure out what could be wrong.
Omar
@theomar3
Jun 25 2016 05:46
Oh whoops. I figured out what was wrong. Nevermind! =P
Catalin Scripcariu
@CatalinScr
Jun 25 2016 05:47
@Marmiz I put a reset function when someone wins
because the game must restart automatically
Claudio Restifo
@Marmiz
Jun 25 2016 05:52

@CatalinScr I know, and I count is as a future implementation. So far I am doing the project with baby steps in order to proceed.
the logic behind my winAlert() seems correct to me, but still I had that weird bug and, even if O win, it alert that X won.

Any ideas where my logic flaws?

This message was deleted
Catalin Scripcariu
@CatalinScr
Jun 25 2016 05:53
wait two min
Claudio Restifo
@Marmiz
Jun 25 2016 05:55
@CatalinScr sure! Thanks
CamperBot
@camperbot
Jun 25 2016 05:55
marmiz sends brownie points to @catalinscr :sparkles: :thumbsup: :sparkles:
:cookie: 395 | @catalinscr |http://www.freecodecamp.com/catalinscr
JasonMChandler
@JasonMChandler
Jun 25 2016 05:57
Are you clearing the variables when you restart?
Claudio Restifo
@Marmiz
Jun 25 2016 05:58
@JasonMChandler this is what I'm doing:
$("#restart").on('click', function(event) {
  $('.cell').empty();
  console.log(a1);
  $('.cell').removeClass('clicked');
  xWin = false;
  oWin=false;
  console.log('reset'+xWin);
  turn = 0;
});
Ivan Aganin
@criativ
Jun 25 2016 06:03
Hello :)
I have an understanding problem - I need to access the "data" out of function... no idea how to do that... Here is the function:
  something = function(data){
    console.log(data);
}
I get a callback = something
Any help is welcome! :)
Carlos Zavaleta
@nerdyamigo
Jun 25 2016 06:06
var addMe = function(num1,num2){
return num1  +  num2; 
}
//is this what you mean?
JasonMChandler
@JasonMChandler
Jun 25 2016 06:07
it looks like you're clearing the classes on reset, but I don't see where you're clearing the a1 a2 etc but maybe I'm missing something. @Marmiz
Claudio Restifo
@Marmiz
Jun 25 2016 06:08

I am probably not doing that.
maybe

$('.cell').empty();

is not doing what i tought it would.

JasonMChandler
@JasonMChandler
Jun 25 2016 06:10
I don't think that will clear your variables. I think that's working on html elements
Catalin Scripcariu
@CatalinScr
Jun 25 2016 06:10
@Marmiz you clear the variables but the problem is when you click on every cell X won. It seems that the problem is from the checkwin function
Andre
@deshon12
Jun 25 2016 06:16
@criativ var something = function(data){
console.log(data);
}
Raj Thakur
@rajkthakur
Jun 25 2016 06:23
guys please test it and review my
https://codepen.io/raj2604/pen/LZpKYg
Ivan Aganin
@criativ
Jun 25 2016 06:25
@deshon12 And what does it do exactly? :)
something is not defined
Marsheek
@Marsheek
Jun 25 2016 06:26

Hey everyone, going through the freecodecamp javascript and am stuck on the escaping sequences in strings challenge 158.

var myStr = "Here is a backslash: \.\n\t\t Here is a new line with two tabs.";

That is my code if anyone could help would really appreciate it
Carlos Zavaleta
@nerdyamigo
Jun 25 2016 06:33
@Marshallgray your not escaping the first \
Catalin Scripcariu
@CatalinScr
Jun 25 2016 06:34
@Marmiz sorry but I don't understand where is the problem.
Carlos Zavaleta
@nerdyamigo
Jun 25 2016 06:34
@Marshallgray
var myStr = "Here is a backslash \\.\n\t\tHere is a new line with two tabs";
Aggrovirus
@Aggrovirus
Jun 25 2016 06:34

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(-10);

Leo Sizaret
@Bungou
Jun 25 2016 06:34
Hello everyone! How do I add a delay to this background change?
$("#img1").hover(function() {
      $(".pageThree").css("background", "#F00");
Aggrovirus
@Aggrovirus
Jun 25 2016 06:35
why I change the covertToF and the output is still 33.8?
Krishna Sai Gullapalli
@Krish2704
Jun 25 2016 06:36
@Aggrovirus you did not multiply 9/5 with celsius
so, your answer will alaways be 33.8
Norvin Burrus
@ndburrus
Jun 25 2016 06:36
@Aggrovirus ...did we forget something, here: fahrenheit = 9 / 5 + 32 ; ? :sparkles: hint: is there function input given (ie a variable, perhaps)?
Aggrovirus
@Aggrovirus
Jun 25 2016 06:38
@ndburrus @Krish2704 thanks I try it again
CamperBot
@camperbot
Jun 25 2016 06:38
aggrovirus sends brownie points to @ndburrus and @krish2704 :sparkles: :thumbsup: :sparkles:
:cookie: 694 | @ndburrus |http://www.freecodecamp.com/ndburrus
:cookie: 463 | @krish2704 |http://www.freecodecamp.com/krish2704
Aggrovirus
@Aggrovirus
Jun 25 2016 06:40
@ndburrus I tried to var celsius but it told me that celsius is already defined
Krishna Sai Gullapalli
@Krish2704
Jun 25 2016 06:40
@Aggrovirus show me what you tried
lizziebethw
@lizziebethw
Jun 25 2016 06:40
Hi how do I get the solution?
Krishna Sai Gullapalli
@Krish2704
Jun 25 2016 06:41
@lizziebethw which solution?
Aggrovirus
@Aggrovirus
Jun 25 2016 06:42
blob
@Krish2704

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

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

@Krish2704 can you also teach me how to take a pic at the small section
not the whole page
Krishna Sai Gullapalli
@Krish2704
Jun 25 2016 06:43
@Aggrovirus not. did you see the formula to find fahrenheit given on the left?
may be try using snipping tool? select whichever part you want and it creates an immage for that
Aggrovirus
@Aggrovirus
Jun 25 2016 06:48
@Krish2704 i solved it thanks
CamperBot
@camperbot
Jun 25 2016 06:48
aggrovirus sends brownie points to @krish2704 :sparkles: :thumbsup: :sparkles:
:warning: aggrovirus already gave krish2704 points
Krishna Sai Gullapalli
@Krish2704
Jun 25 2016 06:49
glad to help
Claudio Restifo
@Marmiz
Jun 25 2016 06:53
@CatalinScr No worries I have sorted out. There were inconsistencies in my code durig the if() stament :)
Catalin Scripcariu
@CatalinScr
Jun 25 2016 06:54
@Marmiz glad to hear that :)
Claudio Restifo
@Marmiz
Jun 25 2016 06:54
@CatalinScr thanks for your help
CamperBot
@camperbot
Jun 25 2016 06:54
marmiz sends brownie points to @catalinscr :sparkles: :thumbsup: :sparkles:
:warning: marmiz already gave catalinscr points
Catalin Scripcariu
@CatalinScr
Jun 25 2016 06:54
np
Anon3333
@Anon3333
Jun 25 2016 07:10

// Example
var ourArr = [ 9, 10, 11, 12];
var ourTotal = 0;

for (var i = 0; i < ourArr.length; i++) {
  ourTotal += ourArr[i];
}

// Setup
var myArr = [ 2, 3, 4, 5, 6];

// Only change code below this line
var total = 0;

for(var i = 0; i < myArr.length; i++) {
  total = myArr[i];
}
Not getting 20 as it should?
Krishna Sai Gullapalli
@Krish2704
Jun 25 2016 07:13
@Anon3333 your total will have the last element of the array
@Anon3333 you're not adding the total with every element of the array
Anon3333
@Anon3333
Jun 25 2016 07:14
@Krish2704 So what should I do to make it add
Krishna Sai Gullapalli
@Krish2704
Jun 25 2016 07:15
@Anon3333 total+= myArr[i]
Anon3333
@Anon3333
Jun 25 2016 07:15
Can you explain to me why that works?
Fernand
@Ferdyboy81
Jun 25 2016 07:17
hi guys what am i doing wrong with this link?
<link rel="stylesheet" type="text/css" href="main.css">
<script type="text/javascript" src="script.js"></script>
for some reason im having problem linking my js to my html and css
Krishna Sai Gullapalli
@Krish2704
Jun 25 2016 07:17
@Anon3333 you're looping over all elements, so for every iteration it adds and stores it in the total
Fernand
@Ferdyboy81
Jun 25 2016 07:17
my file names are index.html main.css and script.js
Krishna Sai Gullapalli
@Krish2704
Jun 25 2016 07:18
total+=myArr[i] is nothing but total= total+myArr[i]
Noor O. Abdikadir
@D35T0Y3R145
Jun 25 2016 07:18
@Ferdyboy81 language
Fernand
@Ferdyboy81
Jun 25 2016 07:19
where should i put it here?<link rel="stylesheet" type="text/css" href="main.css">
<script type="text/javascript" src="script.js"></script>
Krishna Sai Gullapalli
@Krish2704
Jun 25 2016 07:19
@Ferdyboy81 you sure that your file names are correct?
Fernand
@Ferdyboy81
Jun 25 2016 07:19
yes double checked it
Krishna Sai Gullapalli
@Krish2704
Jun 25 2016 07:19
@Ferdyboy81 between the head tags
Fernand
@Ferdyboy81
Jun 25 2016 07:20
yes
Krishna Sai Gullapalli
@Krish2704
Jun 25 2016 07:20
can you show me those files
Noor O. Abdikadir
@D35T0Y3R145
Jun 25 2016 07:21
<script language="JavaScript" type="text/JavaScript"></script> @Ferdyboy81
It can go between your head or body tags
Krishna Sai Gullapalli
@Krish2704
Jun 25 2016 07:21
@D35T0Y3R145 you're missing the src attribute
Noor O. Abdikadir
@D35T0Y3R145
Jun 25 2016 07:22
Where?
Krishna Sai Gullapalli
@Krish2704
Jun 25 2016 07:23
@D35T0Y3R145 in your script tag
Fernand
@Ferdyboy81
Jun 25 2016 07:23
@D35T0Y3R145 thank u sir!
CamperBot
@camperbot
Jun 25 2016 07:23
ferdyboy81 sends brownie points to @d35t0y3r145 :sparkles: :thumbsup: :sparkles:
:cookie: 66 | @d35t0y3r145 |http://www.freecodecamp.com/d35t0y3r145
Noor O. Abdikadir
@D35T0Y3R145
Jun 25 2016 07:23
Your Welcome 😊
Krishna
@Krish2704 isn't the SRC attribute only for HTML links for images?
Or just links in general*
Krishna Sai Gullapalli
@Krish2704
Jun 25 2016 07:26
@D35T0Y3R145 nope. to add javascript, you'll use script tags and to link that to your external js file then you'll give that link in your src attribute
Noor O. Abdikadir
@D35T0Y3R145
Jun 25 2016 07:27
@Krish2704 Thank You I didn't know that.
CamperBot
@camperbot
Jun 25 2016 07:27
d35t0y3r145 sends brownie points to @krish2704 :sparkles: :thumbsup: :sparkles:
:cookie: 465 | @krish2704 |http://www.freecodecamp.com/krish2704
Noor O. Abdikadir
@D35T0Y3R145
Jun 25 2016 07:28
I just started learning java yesterday
Well, JS
Krishna Sai Gullapalli
@Krish2704
Jun 25 2016 07:29
oh okay
Fernand
@Ferdyboy81
Jun 25 2016 07:30
@D35T0Y3R145 dang i thought it worked but still didn't link
<link rel="stylesheet" type="text/css" href="main.css">
<script language="Javascript" type="text/Javascript"></script>
Noor O. Abdikadir
@D35T0Y3R145
Jun 25 2016 07:34
@Krish2704 Any idea's?
Fernand
@Ferdyboy81
Jun 25 2016 07:34
blob
Krishna Sai Gullapalli
@Krish2704
Jun 25 2016 07:34
@D35T0Y3R145 ideas for?
@Ferdyboy81 your css is also not working?
Fernand
@Ferdyboy81
Jun 25 2016 07:35
blob
css and html are working
Prashant Sharma
@30Prashant
Jun 25 2016 07:35

function getIndexToIns(arr, num) {
// Find my place in this sorted array.
arr = arr.sort(function(a, b){return a-b;});
var i = 0;
var j;
while ( i<arr.length) { if (num > arr[i]) {
if (arr[i+1] === null || num < arr[i+1]) {
j = i + 1;
}
} else if (num === arr[i]) {
j = i;
}
i++;
}
return j;
}

getIndexToIns([2, 5, 10], 15);

what's wrong, can anybody tell?
Krishna Sai Gullapalli
@Krish2704
Jun 25 2016 07:37
@Ferdyboy81 paste your js code here
Noor O. Abdikadir
@D35T0Y3R145
Jun 25 2016 07:38
@Ferdyboy81 everything appears imputed correctly from my perspective
Ohhhb hold
@Ferdyboy81 try this in your script
<script src="script.js" type="text/Javascript"></script>
Noor O. Abdikadir
@D35T0Y3R145
Jun 25 2016 07:44
Did that help?
Fernand
@Ferdyboy81
Jun 25 2016 07:44
@D35T0Y3R145 still no luck
ahhhh..... my head hurts
Noor O. Abdikadir
@D35T0Y3R145
Jun 25 2016 07:45
Oh, I'm sorry, that's all I got. Maybe call it quits for now until you've regained focus?
Zelibor
@Zelibor
Jun 25 2016 07:45
Hey, guys... I'm having problem with one javascript challenge.
Can somone help me?
Fernand
@Ferdyboy81
Jun 25 2016 07:45
yah i think thats a good idea! thank you for your help!
Prashant Sharma
@30Prashant
Jun 25 2016 07:46
function getIndexToIns(arr, num) {
  // Find my place in this sorted array.
  arr = arr.sort(function(a, b){return a-b;});
  var i = 0;
  var j;
  while ( i<arr.length) {
    if (num > arr[i]) {
      if (arr[i+1] === null || num < arr[i+1]) {
        j = i + 1;
        break;
      }
    } else if (num === arr[i]) {
      j = i;
      break;
    }
    i++;
  }
  return j;
}

getIndexToIns([2, 5, 10], 15);
https://www.freecodecamp.com/challenges/where-do-i-belong
Can anybody help me out?
Noor O. Abdikadir
@D35T0Y3R145
Jun 25 2016 07:46
It wasn't much if we didn't solve your issue but I'm glad you feel that way @Ferdyboy81
Fernand
@Ferdyboy81
Jun 25 2016 07:48
well thanks for trying to help me thought :)
Zelibor
@Zelibor
Jun 25 2016 07:50
@D35T0Y3R145 Can you help me with some javascript?
Noor O. Abdikadir
@D35T0Y3R145
Jun 25 2016 07:51
I'm inexperienced but i could try
@Zelibor
Zelibor
@Zelibor
Jun 25 2016 07:52
@D35T0Y3R145 hehe. That counts, too.
here it is
Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.

function nextInLine(arr, item) {
// Your code here

return item; // Change this line
}

// Test Setup
var testArr = [1,2,3,4,5];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));

I think i should use .push, . shift and .unshift, but i didn't nake it work
make
UtkarshShukla7
@UtkarshShukla7
Jun 25 2016 07:54
@30Prashant use undefined instead of null
@Zelibor you have to perform 2 out of 4 array operations taught earlier : push,pop,shift,unshift.show wht you tried
Prashant Sharma
@30Prashant
Jun 25 2016 07:56
@UtkarshShukla7 I don't do shits bro
Anyways thanks
CamperBot
@camperbot
Jun 25 2016 07:56
30prashant sends brownie points to @utkarshshukla7 :sparkles: :thumbsup: :sparkles:
:cookie: 716 | @utkarshshukla7 |http://www.freecodecamp.com/utkarshshukla7
Noor O. Abdikadir
@D35T0Y3R145
Jun 25 2016 07:57
I still haven't learned this. But when I do, I'll answer it for you 😁
As a matter of fact, I'll get started right now
UtkarshShukla7
@UtkarshShukla7
Jun 25 2016 07:58
@30Prashant I don't do shits bro meaning ? :smile:
Zelibor
@Zelibor
Jun 25 2016 07:58
@D35T0Y3R145 hehehe. Cool
@UtkarshShukla7 Man, I don't know where to start from...
Noor O. Abdikadir
@D35T0Y3R145
Jun 25 2016 07:59
The people on here I swear!!! Their soo weird yet cool at the same time! Haha
Ayo Isaiah
@ayoisaiah
Jun 25 2016 08:00
@Zelibor Send me the link to the challenge so I can look at it for you
UtkarshShukla7
@UtkarshShukla7
Jun 25 2016 08:00
@Zelibor see the instructions tell you to first push a value into array and then remove a value from it ,So check out previous exercises to know what to do
If you want direct answer I can give you that too
Ayo Isaiah
@ayoisaiah
Jun 25 2016 08:02
@UtkarshShukla7 I wouldn't advise that, always better to explain the underlying concepts and allow the OP figure it out himself
Zelibor
@Zelibor
Jun 25 2016 08:02
@ayoisaiah It is chalenge 174, but don't give me answer just yet
hehe
UtkarshShukla7
@UtkarshShukla7
Jun 25 2016 08:02
@ayoisaiah yeah that's why I am asking him work through the previous exercises
Zelibor
@Zelibor
Jun 25 2016 08:03
First of all, i need to define nextInline, wright?
UtkarshShukla7
@UtkarshShukla7
Jun 25 2016 08:04
@Zelibor nextInLine is the function name which you have to edit
Zelibor
@Zelibor
Jun 25 2016 08:06
@UtkarshShukla7 Maaan, I'm so sorry that I can explain it to you, what is confusing me...
@UtkarshShukla7 Yes, i went through all of that, and i understand it, but....
:)
UtkarshShukla7
@UtkarshShukla7
Jun 25 2016 08:07
@Zelibor so you understand what operations you should use
Zelibor
@Zelibor
Jun 25 2016 08:07
@UtkarshShukla7 YES
:)
UtkarshShukla7
@UtkarshShukla7
Jun 25 2016 08:07
which ones ? @Zelibor
Norvin Burrus
@ndburrus
Jun 25 2016 08:07
@Zelibor this may be useful: Javascript Array Methods: Unshift(), Shift(), Push(), And Pop() :sparkles: to start, how would we: Add the number to the end of the array,?
Zelibor
@Zelibor
Jun 25 2016 08:07
.push, . shift, and .unshift
@UtkarshShukla7
UtkarshShukla7
@UtkarshShukla7
Jun 25 2016 08:07
@Zelibor no just 2 are sufficient
@Zelibor just write the code where they have asked you to write it in the comments
Zelibor
@Zelibor
Jun 25 2016 08:08
Yeah, someone just told me that shihft removes the first element and returns it, but I didn
read about returnig
so i thought i should use .unshift
@UtkarshShukla7 than .push and shift
UtkarshShukla7
@UtkarshShukla7
Jun 25 2016 08:10
@Zelibor you have to edit the function so that whenever it is called it returns a vlue which you provide in your return statement
no just push and shift
Zelibor
@Zelibor
Jun 25 2016 08:11
and var is testArr?
or i need to define it?
UtkarshShukla7
@UtkarshShukla7
Jun 25 2016 08:11
unshifts adds at the starting push at the end .shift removes from starting pop from the end
no its arr that is passed to your function
Norvin Burrus
@ndburrus
Jun 25 2016 08:12
@Zelibor review/check the purposes of the methods that you would like to use... :+1: var means var/iable. and var testVar is the test array value setup for you to use when testing the function (nextInLine). - it is already defined as [1,2,3,4,5]. the code you provide goes below: // Your code here and above: // Test Setup.
@Zelibor how are we doing?
Zelibor
@Zelibor
Jun 25 2016 08:18
@ndburrus
not ot good
UtkarshShukla7
@UtkarshShukla7
Jun 25 2016 08:18
@Zelibor you don't know what named variable(testArr,6) will be passed to your function .So you define your own variables(arr,item) which get the value from the variable passed to your function and then you can use your function variables(arr,Item) to access the value of the passed variable(testArr,6)
Zelibor
@Zelibor
Jun 25 2016 08:18
sometimes i stuck at the most obvius things
Norvin Burrus
@ndburrus
Jun 25 2016 08:19
ok, can you identify the method that can add a number to the end of the array?
Zelibor
@Zelibor
Jun 25 2016 08:19
push
UtkarshShukla7
@UtkarshShukla7
Jun 25 2016 08:19
functions allows reusability
Norvin Burrus
@ndburrus
Jun 25 2016 08:19
@Zelibor great, now can you write the code that accomplishes the push? what would that look like?
Zelibor
@Zelibor
Jun 25 2016 08:20
testArr.push(["i don't know what"], 6);
i believe
Norvin Burrus
@ndburrus
Jun 25 2016 08:21
@Zelibor why are we using testArr? isn't that the testing array?
Zelibor
@Zelibor
Jun 25 2016 08:21
I should define my own?
Norvin Burrus
@ndburrus
Jun 25 2016 08:22
@Zelibor take a look at what the function (nextInLine) receives... (as input). what does it receive?
Zelibor
@Zelibor
Jun 25 2016 08:23
than nextInline.push(["something", 0 ])?
Norvin Burrus
@ndburrus
Jun 25 2016 08:24
@Zelibor think about what is happening. what you just said is that you want to push onto the function. does that make sense? the instructions are asking for a value to be pushed/added to the end of an array (not a function)....
Zelibor
@Zelibor
Jun 25 2016 08:24
Yes, but what array? Should i define one?
Norvin Burrus
@ndburrus
Jun 25 2016 08:25
@Zelibor we need to read the feedback. above, we suggested to look at what the function receives as input.... have we identified that - the input/s? hint: the inputs are between the parentheses...
Zelibor
@Zelibor
Jun 25 2016 08:26
item and arr
Norvin Burrus
@ndburrus
Jun 25 2016 08:27
@Zelibor excellent :smile: ...and which of these 2 items would be the array we need to work with? hint: reference the instructions: Write a function nextInLine which takes an array (arr)...Add the number to the end of the array,
Zelibor
@Zelibor
Jun 25 2016 08:28
That is the problem.
:)
Norvin Burrus
@ndburrus
Jun 25 2016 08:29
@Zelibor what is the problem? can we not identify the array from the information above?
Zelibor
@Zelibor
Jun 25 2016 08:29
I don't know what is arr I should work with
Adam
@alacrity26
Jun 25 2016 08:29
hi, can someone pls help ?

```function titleCase(str) {
str=str.toLowerCase().split(" ");

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

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


  return str[i][0];//[i][0].toUpperCase();
}

//var cap=str[0].toUpperCase();
//return str[i][j];//[i].toUpperCase();

}
//return str;//[0].toUpperCase();
}```

Norvin Burrus
@ndburrus
Jun 25 2016 08:30
@Zelibor what is arr?
Zelibor
@Zelibor
Jun 25 2016 08:30
array
Norvin Burrus
@ndburrus
Jun 25 2016 08:30
@Zelibor do we have any other arrays to work with? ...and is arr received as input to the function nextInLine?
Zelibor
@Zelibor
Jun 25 2016 08:30
testArr
Norvin Burrus
@ndburrus
Jun 25 2016 08:31
@Zelibor are we supposed to do anything to testArr?
Zelibor
@Zelibor
Jun 25 2016 08:31
test, i believe
Norvin Burrus
@ndburrus
Jun 25 2016 08:32
@Zelibor the function testing will occur after we have finished coding. the test code is not to be changed (other than for testing different scenarios). we are focusing on completing the function code, right?
Zelibor
@Zelibor
Jun 25 2016 08:34
Right
Norvin Burrus
@ndburrus
Jun 25 2016 08:34
@Zelibor so which array are we to use (or use the push method on)?
Zelibor
@Zelibor
Jun 25 2016 08:35
I don't know.
UtkarshShukla7
@UtkarshShukla7
Jun 25 2016 08:35
@alacrity26 you can perform slice operation to get the remaining part of the array and add it to the other part which you changed and don't return inside your loop .
Zelibor
@Zelibor
Jun 25 2016 08:35
A new one?
I don't see any defined, except testArr...
Adam
@alacrity26
Jun 25 2016 08:36
@UtkarshShukla7 thanks for responding. mind explaining a lil more? I don't quite get what you mean by slice operation...
CamperBot
@camperbot
Jun 25 2016 08:36
alacrity26 sends brownie points to @utkarshshukla7 :sparkles: :thumbsup: :sparkles:
:cookie: 717 | @utkarshshukla7 |http://www.freecodecamp.com/utkarshshukla7
Norvin Burrus
@ndburrus
Jun 25 2016 08:37
@Zelibor alright. i think you should carefully review the instructions. it is helpful to understand what the exercise is asking for. :sparkles:
Zelibor
@Zelibor
Jun 25 2016 08:37
@ndburrus Ok. I'll do my best
UtkarshShukla7
@UtkarshShukla7
Jun 25 2016 08:38
@alacrity26 https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice
you can extract part of array from the original array using this operation
Zelibor
@Zelibor
Jun 25 2016 08:38
Thanks, man
UtkarshShukla7
@UtkarshShukla7
Jun 25 2016 08:38
@alacrity26 yes
Adam
@alacrity26
Jun 25 2016 08:39
@UtkarshShukla7 thanks, could u pls help check whats wrong with the loop itself? seems like it doesnt go beyond the first word in the string
CamperBot
@camperbot
Jun 25 2016 08:39
alacrity26 sends brownie points to @utkarshshukla7 :sparkles: :thumbsup: :sparkles:
:warning: alacrity26 already gave utkarshshukla7 points
UtkarshShukla7
@UtkarshShukla7
Jun 25 2016 08:41
@alacrity26 its because of your return statement don't return inside the loop
@alacrity26 Just realised I gave you the wrong link .Its this link
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/String/slice
Adam
@alacrity26
Jun 25 2016 08:44
@UtkarshShukla7 tried, but only returns 'i'
UtkarshShukla7
@UtkarshShukla7
Jun 25 2016 08:44
@alacrity26 what's your new code
Adam
@alacrity26
Jun 25 2016 08:44

``` function titleCase(str) {
str=str.toLowerCase().split(" ");

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

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


  return str[i][0];//[i][0].toUpperCase();
}

//var cap=str[0].toUpperCase();
//return str[i][0].toUpperCase();//[i].toUpperCase();

}
//return str;//[0].toUpperCase();
} ```

```
UtkarshShukla7
@UtkarshShukla7
Jun 25 2016 08:45
@alacrity26 return str[i][0];//[i][0].toUpperCase(); should be str[i]= str[i][0].toUpperCase();
@alacrity26 return outside all your for loops
Krishna Sai Gullapalli
@Krish2704
Jun 25 2016 08:46
@alacrity26 your code returns the function in the first iteration itself
@alacrity26 and why do you need j loop for? you're doing nothing with it
UtkarshShukla7
@UtkarshShukla7
Jun 25 2016 08:51
@alacrity26 remember strings are immutable so if you try to change just your first character it won't work
explain immutable
CamperBot
@camperbot
Jun 25 2016 08:51

:point_right: js immutable [wiki]

JavaScript Immutable Types

Immutable means unchangeable i.e. you can't change.

Javascript has lots of immutable types e.g. string primitive type. Try this in your console.

s = "red";
console.log(s[1]); //→ "e"
s[1] = "x";
console.log(s) //→ "red"

the s didn't change! WAT!

:pencil: read more about js immutable on the FCC Wiki

UtkarshShukla7
@UtkarshShukla7
Jun 25 2016 08:54
@alacrity26 you have to extract the first character from string and make changes to the array by replacing that string with a new one .
Adam
@alacrity26
Jun 25 2016 08:54
@UtkarshShukla7 got it. Thanks!
CamperBot
@camperbot
Jun 25 2016 08:54
alacrity26 sends brownie points to @utkarshshukla7 :sparkles: :thumbsup: :sparkles:
:warning: alacrity26 already gave utkarshshukla7 points
UtkarshShukla7
@UtkarshShukla7
Jun 25 2016 08:54
@alacrity26 np :+1:
Zelibor
@Zelibor
Jun 25 2016 08:54
@UtkarshShukla7 @ndburrus Ok, it should be : arr.push(item);// Your code here
return arr.shift();, but i still don't get it... And i wrote it accidentally
;)
Adam
@alacrity26
Jun 25 2016 08:55
@UtkarshShukla7 i am joining it w the substring, and then join it outside of the loop.
do you know any good ways for me to check other ways to solve this?
UtkarshShukla7
@UtkarshShukla7
Jun 25 2016 08:55
@alacrity26 seems correct approach
@Zelibor what didn't you get?
Zelibor
@Zelibor
Jun 25 2016 08:56
Whay it is done like that...
UtkarshShukla7
@UtkarshShukla7
Jun 25 2016 08:56
help title
CamperBot
@camperbot
Jun 25 2016 08:56

:point_right: algorithm title case a sentence [wiki]

Algorithm Title Case a Sentence

:triangular_flag_on_post: Remember to use Read-Search-Ask if you get stuck. Try to pair program :busts_in_silhouette: and write your own code :pencil:

:checkered_flag: Problem Explanation:

We have to return a sentence with title case. This means that the first letter will always be in uppercase and the rest will be in lowercase.

Relevant Links

:pencil: read more about algorithm title case a sentence on the FCC Wiki

UtkarshShukla7
@UtkarshShukla7
Jun 25 2016 08:57
@alacrity26 ^^
@Zelibor you have confusion with arr and testArr
or anything else
Zelibor
@Zelibor
Jun 25 2016 08:58
@UtkarshShukla7 Add the number to the end of the array, then remove the first element of array. and i pushed item
and i thought that arr and item are arguments
and arr is array, accordingly
Maybe it is because english is my second-third language
UtkarshShukla7
@UtkarshShukla7
Jun 25 2016 08:59
@Zelibor they are function parameters and arguments are testArray and 6
Zelibor
@Zelibor
Jun 25 2016 08:59
But sometimes, maaan...
UtkarshShukla7
@UtkarshShukla7
Jun 25 2016 09:00
@Zelibor it happens I am also not that confortable with it but it gets better with time
Shivam Mehta
@shivam13
Jun 25 2016 09:00

problem:
Modify the function checkObj to test myObj for checkProp. If the property is found, return that property's value. If not, return "Not Found"

my solution:

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

function checkObj(checkProp) {
// Your Code Here
if(myObj.hasOwnProperty("checkProp")){
return myObj.checkProp;
}
else{
return "Not Found";
}
}

// Test your code by modifying these values
checkObj("gift");

what can i do for the obtain the right result.

Zelibor
@Zelibor
Jun 25 2016 09:01
@UtkarshShukla7 I believe. I have 0 problems on conversational level, but when it comes to hte termynology, sometimes, i get stuck
UtkarshShukla7
@UtkarshShukla7
Jun 25 2016 09:02
@Zelibor best way is to search on google if you get stuck with terminology .Everyone does that
[1,2,3,4,5] //before push
[1,2,3,4,5,6]//after push
[2,3,4,5,6]//after shift
Shivam Mehta
@shivam13
Jun 25 2016 09:02
can any one help me??
UtkarshShukla7
@UtkarshShukla7
Jun 25 2016 09:03
@shivam13 you have to return the value of property
dickorydock
@dickorydock
Jun 25 2016 09:03
Hi, can someone help me debug this?
UtkarshShukla7
@UtkarshShukla7
Jun 25 2016 09:03
@shivam13 and myObj.hasOwnProperty("checkProp") should be myObj.hasOwnProperty(checkProp)
dickorydock
@dickorydock
Jun 25 2016 09:03
```
for (i=1;i<4;i++){ var buttonName = "#button"+i; $(buttonName).click(function(){ $(".screen").html(i); }); }
Umair Sarfraz
@aquadestructor
Jun 25 2016 09:04
Can any body help me out with a probem in angular unit testing with jasmine?
dickorydock
@dickorydock
Jun 25 2016 09:04
it's setting all the functions for all #button1-#button3 to be html(4) not their own numbers.
Shivam Mehta
@shivam13
Jun 25 2016 09:04
its still not working @UtkarshShukla7
UtkarshShukla7
@UtkarshShukla7
Jun 25 2016 09:05
@shivam13 what are you returning?
Shivam Mehta
@shivam13
Jun 25 2016 09:05
if(myObj.hasOwnProperty(checkProp)){
return myObj.checkProp;
}
else{
return "Not Found";
}
}
Zelibor
@Zelibor
Jun 25 2016 09:05
@UtkarshShukla7 I get all of that. I understand what is asked of me to do, but I don't see how to do that. I got stuck two more times before, but i was able to crack and understand the problem, but with this one it was a thriller, and i still don't get it, although i wrote it.
i even know what methods to do, but...
UtkarshShukla7
@UtkarshShukla7
Jun 25 2016 09:06
@shivam13 use bracket notation instead of dot notation
DVladimirov
@dvladimirov
Jun 25 2016 09:06

Hello everyone have a question here. Is there a better way to do the challenge "Reverse a string".

function reverseString(str) {
 var x=  str.split('').reverse().join('');
  return x;
}

Just asking.

UtkarshShukla7
@UtkarshShukla7
Jun 25 2016 09:06
@Zelibor but??
Adam
@alacrity26
Jun 25 2016 09:06
@UtkarshShukla7 thanks! will read through other solutions. if i find it hard to difficult, do you have any recommendations what I could read, or what kind of exercises i could attempt to understand better?
CamperBot
@camperbot
Jun 25 2016 09:06
alacrity26 sends brownie points to @utkarshshukla7 :sparkles: :thumbsup: :sparkles:
:warning: alacrity26 already gave utkarshshukla7 points
Zelibor
@Zelibor
Jun 25 2016 09:06
I got stuck. :)
dickorydock
@dickorydock
Jun 25 2016 09:06
@dvladimirov looks good to me
Shivam Mehta
@shivam13
Jun 25 2016 09:07
its done thanks @UtkarshShukla7
CamperBot
@camperbot
Jun 25 2016 09:07
shivam13 sends brownie points to @utkarshshukla7 :sparkles: :thumbsup: :sparkles:
:cookie: 718 | @utkarshshukla7 |http://www.freecodecamp.com/utkarshshukla7
Zelibor
@Zelibor
Jun 25 2016 09:07
@UtkarshShukla7 Maybe it will clearify to me when I gain more knowledge...
DVladimirov
@dvladimirov
Jun 25 2016 09:07
because one can read it on the MDN page and it doesn't seem fair ...
it is in the examples ...
dickorydock
@dickorydock
Jun 25 2016 09:09
"Read" is part of "Read-Search-Ask" so i think oyu are OK for following instructions :)
DVladimirov
@dvladimirov
Jun 25 2016 09:10
haha :) agree
Ionatan Mocan
@IonatanMocan
Jun 25 2016 09:11
hey guy s
i have a question

var Car = function() {
// this is a private variable
var speed = 10;

// these are public methods
this.accelerate = function(change) {
speed += change;
};

this.decelerate = function() {
speed -= 5;
};

this.getSpeed = function() {
return speed;
};
};

dickorydock
@dickorydock
Jun 25 2016 09:12
I figured out my javascript issue! Whee!
DVladimirov
@dvladimirov
Jun 25 2016 09:13
What is the issue @IonatanMocan
Ionatan Mocan
@IonatanMocan
Jun 25 2016 09:13
who solved the problem with 'private object properties"
?
myBike.getGear() should return 4 after calling myBike.setGear(4).
this is the problem
and my solution doesn't work

var Bike = function() {

var gear;

// Only change code below this line.

this.setGear = function(number) {
  gear += number;
};

this.getGear = function(number) {
  return gear;
};

};

Dieu Linh Nguyen
@dieulinh
Jun 25 2016 09:13
@IonatanMocan that issue for Bike not for Car, right?
Ionatan Mocan
@IonatanMocan
Jun 25 2016 09:14
yes, for bike
var myBike = new Bike();
at the end they have this thing
that's why the error says
myBike.getGear() should return 3 after calling myBike.setGear(3).
DVladimirov
@dvladimirov
Jun 25 2016 09:15
I think you need to set the gear to 0 each time in the setGear function so that you can pass by the new gear otherwise you don't meet the conditions
at least that is how i went pass it :)
Ionatan Mocan
@IonatanMocan
Jun 25 2016 09:15
sure?
DVladimirov
@dvladimirov
Jun 25 2016 09:15
yes
Ionatan Mocan
@IonatanMocan
Jun 25 2016 09:15
because it says
DVladimirov
@dvladimirov
Jun 25 2016 09:15
:D
Ionatan Mocan
@IonatanMocan
Jun 25 2016 09:15
myBike.gear should remain undefined.
i set gear = 0
but it still doesnt work
var gear = 0;
Dieu Linh Nguyen
@dieulinh
Jun 25 2016 09:16
my solution exactly the same @ltegman
Ionatan Mocan
@IonatanMocan
Jun 25 2016 09:16
doesn't work :worried:
DVladimirov
@dvladimirov
Jun 25 2016 09:16
what was the name
of the challenge
:)
Ionatan Mocan
@IonatanMocan
Jun 25 2016 09:17
Make Object Properties Private
Dieu Linh Nguyen
@dieulinh
Jun 25 2016 09:17
I did the same as you did and it works
I pass that solution
Ionatan Mocan
@IonatanMocan
Jun 25 2016 09:17
paste the code here
please
DVladimirov
@dvladimirov
Jun 25 2016 09:18
you need to set the gear = 0 inside the private method like this
var Bike = function() {

  // Only change code below this line.
var gear = 0;

  this.setGear = function(metric){
    gear = 0;
    gear += metric;
  }
  this.getGear = function(){
    return gear;
  }
};
Dieu Linh Nguyen
@dieulinh
Jun 25 2016 09:18
this.setGear = function(number) {
gear = number;
};
Ionatan Mocan
@IonatanMocan
Jun 25 2016 09:18
oh thank you @dieulinh and @dvladimirov
CamperBot
@camperbot
Jun 25 2016 09:18
ionatanmocan sends brownie points to @dieulinh and @dvladimirov :sparkles: :thumbsup: :sparkles:
:cookie: 243 | @dvladimirov |http://www.freecodecamp.com/dvladimirov
:cookie: 55 | @dieulinh |http://www.freecodecamp.com/dieulinh
DVladimirov
@dvladimirov
Jun 25 2016 09:18
at least that is how i did it :)
Jordan Mizrachi
@jmizrachi
Jun 25 2016 09:18

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

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

// Change the inputs below to test your code
convertToF(30);
having trouble with this
UtkarshShukla7
@UtkarshShukla7
Jun 25 2016 09:21
@Zelibor ah my net is acting up today. Anyways ,for better understanding you should try searching about the highlighted terms and yes sometimes the instructions can confuse you but read them again and again and think what method you should use. It will get better with experience.
DVladimirov
@dvladimirov
Jun 25 2016 09:21
you need to use the celsius parameter from the function created above :)
@jmizrachi
UtkarshShukla7
@UtkarshShukla7
Jun 25 2016 09:21
@jmizrachi use your celsius parameter in conversion
Jordan Mizrachi
@jmizrachi
Jun 25 2016 09:21
yeah thats what I was thinking.... Like
Celcius= ....
@UtkarshShukla7
DVladimirov
@dvladimirov
Jun 25 2016 09:22
at the moment when you are calling the function outside you are giving it celsius but you aren't doing anything with it inside the body of the function
Jordan Mizrachi
@jmizrachi
Jun 25 2016 09:23
ah kk
DVladimirov
@dvladimirov
Jun 25 2016 09:23
and you should look at the formula of fahrenheit again :)
it will help you get trough this
Dimace
@Dimace
Jun 25 2016 09:24
please help me, I have no idea what I am doing wrong, here is the error: "TypeError:Cannot read property 'hasOwnProperty' of undefined".
Jordan Mizrachi
@jmizrachi
Jun 25 2016 09:24
isnt celcius *(9/5)+32
Dimace
@Dimace
Jun 25 2016 09:24
it is exercise Profile Lookup
here is my code
for(var i=0; i<=contacts.length;i++)
{
if(contacts[i].hasOwnProperty(prop)===false)
return "No such property";
}
for(var b=0; b<=contacts.length;b++)
{
if(contacts[b].firstName===firstName)
return contacts[b][prop];
}
return "No such contact";
Zelibor
@Zelibor
Jun 25 2016 09:25
@UtkarshShukla7 Thanks, man. By the way, I understood that challenge, few minutes ago. :)
CamperBot
@camperbot
Jun 25 2016 09:25
:cookie: 719 | @utkarshshukla7 |http://www.freecodecamp.com/utkarshshukla7
zelibor sends brownie points to @utkarshshukla7 :sparkles: :thumbsup: :sparkles:
Jordan Mizrachi
@jmizrachi
Jun 25 2016 09:26
@Dimace use ``` before and after for code readability
Dimace
@Dimace
Jun 25 2016 09:26
ok I get it
but I still cannot solve this task, though it is so simple
Jordan Mizrachi
@jmizrachi
Jun 25 2016 09:27
can you repaste it?
DVladimirov
@dvladimirov
Jun 25 2016 09:27
ah it is not my friend
i wasted 3 hours yesterday trying to solve it
Jordan Mizrachi
@jmizrachi
Jun 25 2016 09:27
@dvladimirov still having trouble haha
DVladimirov
@dvladimirov
Jun 25 2016 09:27
i got over it :)
but i was in a jam
for quite a while
Dimace
@Dimace
Jun 25 2016 09:27
@jmizrachi do you mean all code including code, whic I had by default?
ok

//Setup
var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
},
{
"firstName": "Sherlock",
"lastName": "Holmes",
"number": "0487345643",
"likes": ["Intriguing Cases", "Violin"]
},
{
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["Javascript", "Gaming", "Foxes"]
}
];

function lookUpProfile(firstName, prop){
// Only change code below this line

for(var i=0; i<=contacts.length;i++)
{
if(contacts[i].hasOwnProperty(prop)===false)
return "No such property";
}
for(var b=0; b<=contacts.length;b++)
{
if(contacts[b].firstName===firstName)
return contacts[b][prop];
}
return "No such contact";

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Bob", "number");

DVladimirov
@dvladimirov
Jun 25 2016 09:29
@Dimace you don't need 2 for loops in this challenge :)
Dimace
@Dimace
Jun 25 2016 09:29
sometimes JavaScript looks for me more difficult than C or Java )
DVladimirov
@dvladimirov
Jun 25 2016 09:29
i learned that the hard way :D
Dimace
@Dimace
Jun 25 2016 09:29
but why?
I need to check all elements
I thought
DVladimirov
@dvladimirov
Jun 25 2016 09:29
well i taught one must check first the objects
Dimace
@Dimace
Jun 25 2016 09:29
I mean all objects in the array
DVladimirov
@dvladimirov
Jun 25 2016 09:29
then the key -value pairs
inside them
Dimace
@Dimace
Jun 25 2016 09:29
yep
DVladimirov
@dvladimirov
Jun 25 2016 09:30
but i was wrong :D
only one for loop to loop trough the for objects
in the array
the rest with if else statements
at least that is how i did it :)
there may be other ways to do this that may be more elegant and better than this.
Dimace
@Dimace
Jun 25 2016 09:31
ok I will try to do that
DVladimirov
@dvladimirov
Jun 25 2016 09:31
don't loose hope
i was about to yesterday after 3 hours :D
Dimace
@Dimace
Jun 25 2016 09:31
by the way do you speak russian?
DVladimirov
@dvladimirov
Jun 25 2016 09:31
why you ask ? such a specific question , because of vladimirov in my tag ?
Dimace
@Dimace
Jun 25 2016 09:32
yep
DVladimirov
@dvladimirov
Jun 25 2016 09:32
just curious :)
it is the same kind of language and it is near in pronunciation to russian :)
but great deduction skills
hah
Oxide Debbarma
@oxide94Git
Jun 25 2016 09:33
hey buddies.. how to tweet dynamicaly from a codepen page
Dimace
@Dimace
Jun 25 2016 09:34
@dvladimirov ukrainian?
DVladimirov
@dvladimirov
Jun 25 2016 09:34
nah way cold :D @Dimace
Dimace
@Dimace
Jun 25 2016 09:34
Well, I was mistaken
whatever, thank you for your help
I will try to fix my code
DVladimirov
@dvladimirov
Jun 25 2016 09:35
no problemo
get a coffee or something fresh if you can't think it right now go outside and return after 10 :)
it helps
Dimace
@Dimace
Jun 25 2016 09:36
it is a useful hint)
Jordan Mizrachi
@jmizrachi
Jun 25 2016 09:49
@dvladimirov @UtkarshShukla7 thanks
CamperBot
@camperbot
Jun 25 2016 09:49
jmizrachi sends brownie points to @dvladimirov and @utkarshshukla7 :sparkles: :thumbsup: :sparkles:
:cookie: 244 | @dvladimirov |http://www.freecodecamp.com/dvladimirov
:cookie: 720 | @utkarshshukla7 |http://www.freecodecamp.com/utkarshshukla7
Jordan Mizrachi
@jmizrachi
Jun 25 2016 09:51
still a bit unsure how to do it though...

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

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

// Change the inputs below to test your code
convertToF(30);
DVladimirov
@dvladimirov
Jun 25 2016 09:53
so the formula is exactly (celsius * (9/5)) + 32)
try to use it exactly as it is stated in the wiki
and you won't have any problems
Brendan Kinahan
@BKinahan
Jun 25 2016 10:10
@jmizrachi note that the line celsius=fahrenheit; does two things: declares a new (global) variable called celcius (because the spelling does not match the existing function parameter celsius), and assigns to it the value of fahrenheit (which is 33.8 from the line before).
Le Anh Duy (Andrew)
@leanhduy1998
Jun 25 2016 10:16
Hi guys, I don't really know how to do the No Repeats Please problem. How do you generate all Permutations using heap? I looked at the heap algorithm but still didn't understand it. I'm struggling with this problem.
Brendan Kinahan
@BKinahan
Jun 25 2016 10:17
@leanhduy1998 did you look at the example of Heap's Algorithm in the FCC wiki, or have you read the actual wikipedia article about it too?
@leanhduy1998 don't worry about the struggle, that's part of understanding recursion :)
Le Anh Duy (Andrew)
@leanhduy1998
Jun 25 2016 10:18
@BKinahan Yes I did look at Wiki, I understand the concept, but don't really understand how the code works
@BKinahan I would be really appreciate if you can help me sir
*I would really appreciate
Brendan Kinahan
@BKinahan
Jun 25 2016 10:24
@leanhduy1998 It's a bit difficult to explain the entire process. Are there any specific parts which you have trouble understanding?
Le Anh Duy (Andrew)
@leanhduy1998
Jun 25 2016 10:30
procedure generate(n : integer, A : array of any):
if n = 1 then
output(A)
else
for i := 0; i < n - 1; i += 1 do
generate(n - 1, A)
if n is even then
swap(A[i], A[n-1])
else
swap(A[0], A[n-1])
end if
end for
generate(n - 1, A)
end if
I do know how to solve this problem using Heap, but I don't know how to put it into codesa
@BKinahan
Joris Boschmans
@jorisboschmans
Jun 25 2016 10:37
when i subtract 0.01 from 0.02 i get 0.0099999999. How can i solve this?
glebumarov
@glebumarov
Jun 25 2016 10:38

var nyc = {
fullName: "New York City",
mayor: "Bill de Blasio",
population: 8000000,
boroughs: 5
};

for (var i=0; i<nyc.length; i++) {
console.log (nyc[i]);
}

Why it doesn't it console.log my list of my values?
Stephen James
@sjames1958gm
Jun 25 2016 10:39
@glebumarov objects don't have lengths or indexes
Brendan Kinahan
@BKinahan
Jun 25 2016 10:40
@leanhduy1998 you will need to think about how to implement the helper functions in that pseudocode. First, output(A) can be replaced with some code that pushes (A) to an array of results you build up as the function goes through the pemutations (this does not need to be a separate function). Then you should also think about how a swap() helper function should work to swap the positions of two values in your array.
Stephen James
@sjames1958gm
Jun 25 2016 10:40
You can use for (key in nyc) { console.log(nyc[key])}
Brendan Kinahan
@BKinahan
Jun 25 2016 10:41
@jorisboschmans that's a floating point precision error. you can fix it by multiplying your starting numbers by 100 and then dividing your result by 100, or you can fix it by rounding the result. (not the default Math.round() will round to the nearest integer)
Joris Boschmans
@jorisboschmans
Jun 25 2016 10:41
@BKinahan ok i'll give that a try
glebumarov
@glebumarov
Jun 25 2016 10:43
@sjames1958gm Thanks. It actually works. What a noob I am
CamperBot
@camperbot
Jun 25 2016 10:43
glebumarov sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1650 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jun 25 2016 10:44
@glebumarov Keep asking and learning and noob no more :)
Le Anh Duy (Andrew)
@leanhduy1998
Jun 25 2016 10:46
@BKinahan on second thought, I don't really think I understand how recursion works in this problem. How would you right pseudocode for this picture? https://camo.githubusercontent.com/b03b14d937879d36804ead55a10d4d73712b9a96/68747470733a2f2f692e696d6775722e636f6d2f7a466d356752782e706e67
Brendan Kinahan
@BKinahan
Jun 25 2016 10:48
@leanhduy1998 that's a different implementation, not using Heap's
Le Anh Duy (Andrew)
@leanhduy1998
Jun 25 2016 10:48
@BKinahan oh I see, that's why I'm so confused with that
Joris Boschmans
@jorisboschmans
Jun 25 2016 10:49
@BKinahan It worked thanks!
CamperBot
@camperbot
Jun 25 2016 10:49
jorisboschmans sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:star2: 1810 | @bkinahan |http://www.freecodecamp.com/bkinahan
DIO
@dhrubesh
Jun 25 2016 10:53
I am in the factorial lesson, can anyone look at the code tell me whats wrong in it?

function factorialize(num) {
  for(var i=0;i<=num;i++){
    num*=i;
  }



  return num;
}

factorialize(5);
Brendan Kinahan
@BKinahan
Jun 25 2016 10:56
@dhrubesh the first step of your loop sets num to 0 by multiplying it by 0, and every subsequent step results in 0 from multiplication with 0
Keone Martin
@Athaman
Jun 25 2016 10:56
@dhrubesh becaus you start your loop at 0 everything will be 0
damn, so close.
just start your loop at 1 instead and it should run smooth.
oh, actually you should probably also have it just be <num not = to because you don't want to times it by itself.
Le Anh Duy (Andrew)
@leanhduy1998
Jun 25 2016 10:57
@BKinahan For the first iteration, n=4, i=0, so we swap (A[0] with A[4-1]). It doesn't look like the first step of the picture
DIO
@dhrubesh
Jun 25 2016 10:57
@BKinahan @Athaman I figured it out just after I posted this :p but still its not running successfully
Keone Martin
@Athaman
Jun 25 2016 10:58
<= is also breaking it, factoring should start at the next number down and shouldn't involve num*num
just get rid of the = and i think you're good.
Brendan Kinahan
@BKinahan
Jun 25 2016 10:59
right, 5*4*3*2*1 and not 5*5*4*3*2*1 @dhrubesh
Charles Bakar
@charlesBak
Jun 25 2016 11:00
issue.JPG
hi i cant bring my code to passt the last test case. can anybody help me?
DIO
@dhrubesh
Jun 25 2016 11:02
@BKinahan neither this is working

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



  return num;
}

factorialize(5);
Keone Martin
@Athaman
Jun 25 2016 11:03
oh wait... uhmm you can't use num as you're check because it keeps increasing each loop so you'll never catch it
Brendan Kinahan
@BKinahan
Jun 25 2016 11:03
oh yeah :P
Zelibor
@Zelibor
Jun 25 2016 11:03
a little bit of help?
Keone Martin
@Athaman
Jun 25 2016 11:03
you can just set var x = num; and use x instead in the loop declaration
Brendan Kinahan
@BKinahan
Jun 25 2016 11:04
or you can set i to equal num-1 as the first expression of the loop statement and decrement i instead of incrementing
Zelibor
@Zelibor
Jun 25 2016 11:05
@UtkarshShukla7 Are you here?
Keone Martin
@Athaman
Jun 25 2016 11:06
@BKinahan that's a neater solution actually, i think i went with that in my solve
DIO
@dhrubesh
Jun 25 2016 11:06
@BKinahan if I do the decrement thing then “0! is not equal to 1”

function factorialize(num) {

  for(i=num-1;i>0;i--){
    num*=i;
  }




  return num;
}

factorialize(5);
Brendan Kinahan
@BKinahan
Jun 25 2016 11:07
@dhrubesh well 0 is a special case anyway, for your solution
DIO
@dhrubesh
Jun 25 2016 11:08
@BKinahan so how do I do it?
Brendan Kinahan
@BKinahan
Jun 25 2016 11:08
@dhrubesh you can just start with "if num is zero, return 1" and then the loop won't even have to run
or use another variable to store the accumulated value, and start it at 1
DIO
@dhrubesh
Jun 25 2016 11:09
function factorialize(num) {

  if(num>0){for(i=num-1;i>0;i--){
    num*=i;
  }
           }
  else{
    num=1;
  }



  return num;
}

factorialize(5);
@BKinahan lol thats what i did THNX :D
CamperBot
@camperbot
Jun 25 2016 11:09
dhrubesh sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:star2: 1811 | @bkinahan |http://www.freecodecamp.com/bkinahan
Zelibor
@Zelibor
Jun 25 2016 11:10
@BKinahan Can you help me with some javascript chalenge?
Brendan Kinahan
@BKinahan
Jun 25 2016 11:10
a more advanced solution: const factorialize = n => n===0 ? 1 : n*factorialize(n-1); @dhrubesh :P
@Zelibor possibly! which challenge is it?
Zelibor
@Zelibor
Jun 25 2016 11:10
@BKinahan #191
golf code
Brendan Kinahan
@BKinahan
Jun 25 2016 11:11
@Zelibor (challenges aren't numbered, by the way, because the number of points you have can inscrease in other ways, so you should just use the title)
Charles Bakar
@charlesBak
Jun 25 2016 11:11
@dhrubesh you can write it with recursion
Brendan Kinahan
@BKinahan
Jun 25 2016 11:11
@Zelibor what have you tried so far?
Charles Bakar
@charlesBak
Jun 25 2016 11:11

function fac(num){
var fact;
if(num == 0 || num == 1)
return 1;
else
return num * fac(num-1);
}

console.log(fac(5));

Zelibor
@Zelibor
Jun 25 2016 11:11

function golfScore(par, strokes) {
// Only change code below this line
if (strokes = 1){
return "Hole-in-one!";
} else if( strokes<= par-2){
return "Eagle";
} else if ( strokes < par-1){
return "Birdie";
} else if ( strokes != par){
return "Par";
} else if ( strokes > par+1){
return"Bogey";
} else if (strokes > par+2){
return"Double Bogey";
}else if (strokes >= par+3){
return "Go Home";
}

return "Change Me";
// Only change code above this line
}

// Change these values to test
golfScore(5, 4);

DIO
@dhrubesh
Jun 25 2016 11:11
@BKinahan OH man! I could have dowe that!
@charlesBak thnx
CamperBot
@camperbot
Jun 25 2016 11:11
dhrubesh sends brownie points to @charlesbak :sparkles: :thumbsup: :sparkles:
:cookie: 158 | @charlesbak |http://www.freecodecamp.com/charlesbak
Zelibor
@Zelibor
Jun 25 2016 11:11
@BKinahan Ok
Brendan Kinahan
@BKinahan
Jun 25 2016 11:12
@Zelibor I think "Go Home" should actually be "Go Home!"
Zelibor
@Zelibor
Jun 25 2016 11:12
@BKinahan It is golf codechallenge
@BKinahan Yes, but it still isn't it
@BKinahan Do you want me to send you text of the challenge?
Brendan Kinahan
@BKinahan
Jun 25 2016 11:13
@Zelibor } else if ( strokes != par){ is incorrect. Par is when strokes == par
Charles Bakar
@charlesBak
Jun 25 2016 11:13
@dhrubesh my pleasure
Zelibor
@Zelibor
Jun 25 2016 11:13
@BKinahan I was just writing you about that line..:)
Rafał Goławski
@rago4
Jun 25 2016 11:13
function sumPrimes(num) {
    var count = 0;
    var sum = 0;
    var arr = [];

      for(i = 1; i <= num; i++) {
          count = 0;
          for(j = 1; j <= num; j++) {
              if(i % j === 0)
                  count++;
          }
          if(count == 2)
              arr.push(i);
      }

     for(i = 0; i < arr.length; i++)
         sum += arr[i];

     return sum;
}
For sumPrimes(10); it works fine, but not for sumPrimes(977);
Can someone tell me why?
Zelibor
@Zelibor
Jun 25 2016 11:13
@BKinahan Still not done
Brendan Kinahan
@BKinahan
Jun 25 2016 11:14
@Zelibor and for Hole-in-one, you should use == instead of =, because = is the assignment operator and not a test for equality.
Zelibor
@Zelibor
Jun 25 2016 11:14
@BKinahan Ok
Brendan Kinahan
@BKinahan
Jun 25 2016 11:15
@Zelibor the rest of the problems are due to using comparisons other than == when you should be using ==, too.
@Zelibor Only "Eagle" and "Go Home!" need different comparisons
@Zelibor and you can remove return "Change Me"; It is not needed.
Mona Jalal
@monajalal
Jun 25 2016 11:16
I have heard to always use ===
Anon3333
@Anon3333
Jun 25 2016 11:16

//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUpProfile(firstName, prop){
// Only change code below this line
  if(contacts[firstName] === firstName && prop === contacts[prop]) {
    return contacts[prop];
  } else if(contacts[firstName] !== firstName) {
    return "No such contact";
  } else if(prop !== contacts[prop]) {
    return "No such property";
  }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
What's wrong with my code, it only returns no such contact, but others won't work.
Zelibor
@Zelibor
Jun 25 2016 11:17
@BKinahan Ok. thanks. So i need to change out those two lines? "Eagle" and "Go Home!"?
CamperBot
@camperbot
Jun 25 2016 11:17
zelibor sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:star2: 1812 | @bkinahan |http://www.freecodecamp.com/bkinahan
Brendan Kinahan
@BKinahan
Jun 25 2016 11:17
@rago4 your code works for me; maybe your browser is too slow :) there are more efficient ways to determine whether a number is prime, by the way. For example you only have to check whether it is divisible by each number up to the square root of num.
@Zelibor those lines are fine, but the other ones should use ==
Norberto
@nortocode
Jun 25 2016 11:17
@Anon3333 contacts['likes'] doesn't exist
Zelibor
@Zelibor
Jun 25 2016 11:17
@BKinahan Oh, ok. Thank you, man
CamperBot
@camperbot
Jun 25 2016 11:17
zelibor sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:warning: zelibor already gave bkinahan points
Brendan Kinahan
@BKinahan
Jun 25 2016 11:18
@Anon3333 contacts is an array of objects
Mona Jalal
@monajalal
Jun 25 2016 11:19
any idea why this doesn't work? It's a combination of boostrap and jQuery
    $(".navbar-collapse li").hover(function(){$this.css('background-color', $this.data('red'))})
Brendan Kinahan
@BKinahan
Jun 25 2016 11:19
@monajalal I suppose it's best practice to always use === unless you want to allow for equality between different types (for example 0 == false // true can be useful in certain cases)
Jason Keenan
@raavin
Jun 25 2016 11:20
@rago4 what result are you getting. You might need to use Math.sqrt to get the maximum number you need to remove from the list. To be honest though, I haven't been able to get mine working :(
Brendan Kinahan
@BKinahan
Jun 25 2016 11:20
@monajalal but most of the time == is sufficient for simple comparisons like the ones in Golf Code
Charles Bakar
@charlesBak
Jun 25 2016 11:20
@monajalal try to write this in parenthesis like this $(this)
Rafał Goławski
@rago4
Jun 25 2016 11:20
@BKinahan thanks :D I figured it out. I just had to add //no protect under second for loop
CamperBot
@camperbot
Jun 25 2016 11:20
rago4 sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:star2: 1813 | @bkinahan |http://www.freecodecamp.com/bkinahan
Brendan Kinahan
@BKinahan
Jun 25 2016 11:21
@monajalal that depends on what this is referring to in the second case, and where the data property is.
Anon3333
@Anon3333
Jun 25 2016 11:22
Still don't know what to do on this? Lesson: Profile Lookup
Rafał Goławski
@rago4
Jun 25 2016 11:23
@raavin I got good result but it was something about compiler. I just had to add comment // noprotectunder second for loop cause compiler thought that it is infinite loop
Gediminas
@Eskarias
Jun 25 2016 11:23
Hi all. So, I've run into a bit of a problem. Working on a "Record Collection". Has something to do with JSON I believe. But the link that's given for a JSON refresher just leads to an error "We couldn't find a challenge with this name". Any idea what it should be or where I could read up on it?
Jason Keenan
@raavin
Jun 25 2016 11:26
@rago4 Nice
svexas
@svexas
Jun 25 2016 11:29
hey guys, I have problem with weather API. To use geolocation on codepen in chrome, you need to use https://, to access api, i can't use https:// what should i do and how could i fix this problem?
Charles Bakar
@charlesBak
Jun 25 2016 11:30
hi guys how do share my code in the chat room instead of sending pics?
Rafał Goławski
@rago4
Jun 25 2016 11:30
use code
@charlesBak use ```
Keone Martin
@Athaman
Jun 25 2016 11:31
help format
CamperBot
@camperbot
Jun 25 2016 11:31

:point_right: code formatting [wiki]

Multi line Code

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

Single line Code

This an inline `<paste code here>` code formatting with a single backtick() at _start_ and _end_ around thecode`.

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

Keone Martin
@Athaman
Jun 25 2016 11:31
@charlesBak feel free to play around with it a little bit, i think most of us messed it up the first time so don't worry :)
@Eskarias they seem to have taken away the challenge about working with objects. if you look in the map for 'object notation' there is a challenge on accessing object properties with bracket notation which may be helpful
Telychko Vitalii
@TelychkoVitalii
Jun 25 2016 11:33
Hi people
Mona Jalal
@monajalal
Jun 25 2016 11:33
ok I have this now but it's not changing the color of navbar item when I hover on them??? :/
 $(".navbar-collapse li").hover(function(){$(this).css('background-color', $(this).data('red'))})
Telychko Vitalii
@TelychkoVitalii
Jun 25 2016 11:33
please help with this exercise
what s wrong?
Gediminas
@Eskarias
Jun 25 2016 11:33
@Athaman Ah, alright. Thanks :)
CamperBot
@camperbot
Jun 25 2016 11:33
eskarias sends brownie points to @athaman :sparkles: :thumbsup: :sparkles:
:cookie: 456 | @athaman |http://www.freecodecamp.com/athaman
Telychko Vitalii
@TelychkoVitalii
Jun 25 2016 11:33

function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for (var i = 0; i < arr.length; i++) {
for (var j = 0; j < arr[i]; j++) {
console.log(arr[i][j]);
product *= arr[i][j];
}
}
// Only change code above this line
return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);

Jordan Mizrachi
@jmizrachi
Jun 25 2016 11:34
@BKinahan thanks
CamperBot
@camperbot
Jun 25 2016 11:34
jmizrachi sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:star2: 1814 | @bkinahan |http://www.freecodecamp.com/bkinahan
Keone Martin
@Athaman
Jun 25 2016 11:34
@Eskarias also feel free to ask questions here about it, we can help you out with general questions as well as specific ones if you let us know anything you find challenging.
Charles Bakar
@charlesBak
Jun 25 2016 11:35
This message was deleted
Keone Martin
@Athaman
Jun 25 2016 11:35
@TelychkoVitalii what's the name of the challenge?
Telychko Vitalii
@TelychkoVitalii
Jun 25 2016 11:35
@Athaman Nesting For Loops
Keone Martin
@Athaman
Jun 25 2016 11:36
@charlesBak haha it happens to the best of us :D
Mona Jalal
@monajalal
Jun 25 2016 11:36
how do I handle hover off? I mean after I am done with hovering, how should I get back the color to its normal mode?
Keone Martin
@Athaman
Jun 25 2016 11:36
@TelychkoVitalii oh, for the j loop you need to use arr[i].length not just arr[i]
Charles Bakar
@charlesBak
Jun 25 2016 11:36
This message was deleted
Keone Martin
@Athaman
Jun 25 2016 11:36
give that a shot and see how you go
Mona Jalal
@monajalal
Jun 25 2016 11:37
    $(".navbar-collapse li").hover(function(){$(this).css('background-color', 'red')})
Telychko Vitalii
@TelychkoVitalii
Jun 25 2016 11:38
@Athaman do not want to work

function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for (var i = 0; i < arr.length; i++) {
for (var j = 0; j < arr[i].length; j++) {
product *= arr[i];
}
}
// Only change code above this line
return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);

Keone Martin
@Athaman
Jun 25 2016 11:38
and product *=arr[i][j];
otherwise it will be trying to multiply a number by the array stored in arr[i] which is confusing
Brendan Kinahan
@BKinahan
Jun 25 2016 11:39
@monajalal http://api.jquery.com/hover/ You can use two handlers, or just one that happens on both in & out (which can toggle a class, for example)
Telychko Vitalii
@TelychkoVitalii
Jun 25 2016 11:39
thnx man!I am your debtor!
@Athaman thnx man!I am your debtor!
CamperBot
@camperbot
Jun 25 2016 11:39
telychkovitalii sends brownie points to @athaman :sparkles: :thumbsup: :sparkles:
:cookie: 457 | @athaman |http://www.freecodecamp.com/athaman
Keone Martin
@Athaman
Jun 25 2016 11:40
@TelychkoVitalii my pleasure my friend.
Mona Jalal
@monajalal
Jun 25 2016 11:40
I saw the api but didn't understand!
Keone Martin
@Athaman
Jun 25 2016 11:40
@charlesBak feel free to private message me to practice your formatting if you don't want to bother the channel :)
Charles Bakar
@charlesBak
Jun 25 2016 11:41
thanks @Athaman
CamperBot
@camperbot
Jun 25 2016 11:41
charlesbak sends brownie points to @athaman :sparkles: :thumbsup: :sparkles:
:cookie: 458 | @athaman |http://www.freecodecamp.com/athaman
Keone Martin
@Athaman
Jun 25 2016 11:43
@charlesBak if you look on the left there should be a direct convo with me open there
Artem
@foolishhare
Jun 25 2016 11:53
Есть кто из Украины. Кто разбирается в ангуляре?
Keone Martin
@Athaman
Jun 25 2016 11:54
I don't speak ... russian? (sorry if that's horribly offensively the wrong language)
Radosław
@BoguslawskiR
Jun 25 2016 11:55

Any idea why this code don't work ?
for(var i = 0; i < arr.lenght; i++)
{
var a = 0;
for(var j = 0; j < arr[i].lenght; j++)
{

            if(a<=arr[i][j]) {
              a = arr[i][j];
            }

          }
    arr[i] = a;

  }

return arr;

Zelibor
@Zelibor
Jun 25 2016 11:55
@foolishhare Ja ni z Ukrajini, ale rozmovljaju Ukrajinskoju. Ja takoz newbee, tomu ne mozu dopomogti zi tvojeju spravoju, lise hotiv privitaty. :)
Keone Martin
@Athaman
Jun 25 2016 11:55
@BoguslawskiR you have a typoe in the way you spell length for starters
Brendan Kinahan
@BKinahan
Jun 25 2016 11:55
Keone Martin
@Athaman
Jun 25 2016 11:56
both your loops are written arr.lenght instead of arr.length
Radosław
@BoguslawskiR
Jun 25 2016 11:56
Oh my god...
Keone Martin
@Athaman
Jun 25 2016 11:56
:D
Brendan Kinahan
@BKinahan
Jun 25 2016 11:56
I don't think there's a Ukrainian room...
Artem
@foolishhare
Jun 25 2016 11:56
@Zelibor Дякую. І тобі вітаннячка))
Zelibor
@Zelibor
Jun 25 2016 11:56
@foolishhare :)
Artem
@foolishhare
Jun 25 2016 11:56
@BKinahan thanks
CamperBot
@camperbot
Jun 25 201