These are chat archives for FreeCodeCamp/HelpJavaScript

1st
Jul 2017
Saif Ur Rahman
@saifsmailbox98
Jul 01 2017 00:00
@ednor if break is not present then all the code below the case matched will get executed.
CallMeOrange
@EgnaroDev
Jul 01 2017 00:00
switch(...) {
case: ..
.....
break;
case:...
....
}
kumquatfelafel
@kumquatfelafel
Jul 01 2017 00:00

So I'm doing this kata on code wars where the goal is to remove the letter 'o'. https://www.codewars.com/kata/beginner-friendly-remove-the-letter-o/train/javascript
Here's what I came up with after a brief struggle with the obsequious lobster that occupies a certain corner of my mind... I think it's pretty good, but I was wondering if anybody can come up with a better solution??

function removeO(string){
   return string.replace('o','').split('').filter(char => string.split(/\w/).reverse().join(string.concat(" ")).split(' ').splice(0,1).join().replace(/[^oO]/g,"").indexOf(char)).join("");
}

Any thoughts?

Saif Ur Rahman
@saifsmailbox98
Jul 01 2017 00:00
@kumquatfelafel :wave:
kumquatfelafel
@kumquatfelafel
Jul 01 2017 00:00
hi :o
Ednor
@ednor
Jul 01 2017 00:02

Okay, what about that code ?


var count = 0;

function cc(card) {
  // Only change code below this line
  switch (cc) {
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      return count++;
    case 7:
    case 8:
    case 9:
      return 0;
    case 10:
    case 'J':
    case 'Q':
    case 'K':
    case 'A':
      return count--;
  }



  return "-5 Hold";
  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');

do you remember the Counting Cards challenge ?

Saif Ur Rahman
@saifsmailbox98
Jul 01 2017 00:02
@kumquatfelafel I tried return string.replace(/o/gi,"");
And got Time: 432ms Passed: 104 Failed: 0
don't know how codewars work
@ednor dont return from the switch
just change the value of count from there
just count++ and not return count++
Ednor
@ednor
Jul 01 2017 00:03
@saifsmailbox98 , ok let me try
Saif Ur Rahman
@saifsmailbox98
Jul 01 2017 00:03
And read the instructions again.
Ednor
@ednor
Jul 01 2017 00:06
my new code:
```

var count = 0;

function cc(card) {
  // Only change code below this line
  switch (cc) {
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
     count++;
      break;
    case 7:
    case 8:
    case 9:
     break;
    case 10:
    case 'J':
    case 'Q':
    case 'K':
    case 'A':
      count--;
      break;
  }



  return "-5 Hold";
  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
And it still not works
CallMeOrange
@EgnaroDev
Jul 01 2017 00:07
@ednor why do you need that last break;?
Nickey Pickorita
@Pickorita
Jul 01 2017 00:07
hey everyone
could someone please help me with javascript?
CallMeOrange
@EgnaroDev
Jul 01 2017 00:08
and what happened to case 7 to 9? where is that thing before break;?
Ednor
@ednor
Jul 01 2017 00:08
@MCTwoDigitZero, with or without it, the code doesn't work
Saif Ur Rahman
@saifsmailbox98
Jul 01 2017 00:08

you can remove this part

  case 7:
    case 8:
    case 9:
     break;

@ednor

@ednor Now based on the value of count return Bet or Hold along with count.
CallMeOrange
@EgnaroDev
Jul 01 2017 00:09
@ednor Yeah but you dont need last break;
Saif Ur Rahman
@saifsmailbox98
Jul 01 2017 00:09
there's no problem with that. @MCTwoDigitZero
Ednor
@ednor
Jul 01 2017 00:09
image.png
@saifsmailbox98 , here is the challenge
Saif Ur Rahman
@saifsmailbox98
Jul 01 2017 00:09
@ednor switch(card) not cc. cc is the name of the function.
image.png
@ednor
Nickey Pickorita
@Pickorita
Jul 01 2017 00:11
Hi could someone please check my javascript code?
kumquatfelafel
@kumquatfelafel
Jul 01 2017 00:11
@saifsmailbox98 That's too good. :o
Saif Ur Rahman
@saifsmailbox98
Jul 01 2017 00:12
@kumquatfelafel was that right?
kumquatfelafel
@kumquatfelafel
Jul 01 2017 00:12
@Pickorita sure. So long as it's not too long, feel free to just post directly in chat
@saifsmailbox98 I don't know. My mind is too blown to try your solution. :p
The non lengthiness of it has shocked me to my very core. ;)
Nickey Pickorita
@Pickorita
Jul 01 2017 00:13
@kumquatfelafel its not, around 30 lines
I've been trying to calculate area of a circle and I did it successfully
now been trying to do that for cuboid but its not working
not sure what's wrong
Can you check it please?
M-C-Haker
@M-C-Haker
Jul 01 2017 00:15

Ok I got it, but can someone please help me understand why a) works and b) doesn’t?

a)

function palindrome(str) {

var removeChar = str.replace(/[^A-Z0-9]/ig, "").toLowerCase();

var checkPalindrome = removeChar.split('').reverse().join('');

return (removeChar === checkPalindrome);

}

palindrome("eye");

b)

function palindrome(str) {

var pali = str.replace(/[^0-9a-z]/gi, '').toLowerCase().split("").reverse().join();

if (str === pali) {

return true;

}

else {

return false;

}

}

palindrome("eye");

Saif Ur Rahman
@saifsmailbox98
Jul 01 2017 00:16
@M-C-Haker because pali is the reversed and cleaned string while str is the same orignal string that contains junks like %$#@_!
M-C-Haker
@M-C-Haker
Jul 01 2017 00:16
So obvious thank you too caught up in it i guess
kumquatfelafel
@kumquatfelafel
Jul 01 2017 00:17
^ string.replae will return new string not modify old
Saif Ur Rahman
@saifsmailbox98
Jul 01 2017 00:17
@Pickorita how do you get the input?
M-C-Haker
@M-C-Haker
Jul 01 2017 00:17
Just decided to split it in two parts and got it to work but was having trouble figuring out why until you explained
kumquatfelafel
@kumquatfelafel
Jul 01 2017 00:17
@saifsmailbox98 wondering this as well.. not seeing anything??
Saif Ur Rahman
@saifsmailbox98
Jul 01 2017 00:17
@M-C-Haker thats why I told you to console log it.
Nickey Pickorita
@Pickorita
Jul 01 2017 00:17
how do you mean? @saifsmailbox98
Saif Ur Rahman
@saifsmailbox98
Jul 01 2017 00:18
@Pickorita like where is the element #hSurfaceArea
M-C-Haker
@M-C-Haker
Jul 01 2017 00:18
Lol not at my home computer and was going to have to try and track down a link to get it to display on codepend or fiddle
Saif Ur Rahman
@saifsmailbox98
Jul 01 2017 00:19
@Pickorita try https://repl.it/JJ6h
Nickey Pickorita
@Pickorita
Jul 01 2017 00:20
i replaced
its not working
where would I find a tutorial on how to calculate area of a cuboid with javascript?
kumquatfelafel
@kumquatfelafel
Jul 01 2017 00:21
Your surface area formula is fine.
Saif Ur Rahman
@saifsmailbox98
Jul 01 2017 00:22
@Pickorita I would suggest doing the jQuery part from freeCodeCamp.
Nickey Pickorita
@Pickorita
Jul 01 2017 00:22
thanks
Saif Ur Rahman
@saifsmailbox98
Jul 01 2017 00:22
You can try your js on https://repl.it/languages/javascript, your code is alright.
Here is your code : https://repl.it/JJ6h
Nickey Pickorita
@Pickorita
Jul 01 2017 00:23

clear
Native Browser JavaScript

SyntaxError: Unexpected token (1:0)

kumquatfelafel
@kumquatfelafel
Jul 01 2017 00:23
@Pickorita In that JS portion, there is a V. Click that and click analyze JS.
Saif Ur Rahman
@saifsmailbox98
Jul 01 2017 00:24
bye :wave: :zzz:
Nickey Pickorita
@Pickorita
Jul 01 2017 00:24
I tried
this is what I get
^screenshot above
Saif Ur Rahman
@saifsmailbox98
Jul 01 2017 00:24
@Pickorita you are again targeting the DOM elements
like hLength, etc.
kumquatfelafel
@kumquatfelafel
Jul 01 2017 00:25
@saifsmailbox98 see ya
Nickey Pickorita
@Pickorita
Jul 01 2017 00:25
yea
I'm trying to calculate are of the cuboid
area* sorry
Saif Ur Rahman
@saifsmailbox98
Jul 01 2017 00:25
@Pickorita they don't exist, you need to create them in the section HTML of codepen.
you can edit your comments.
Nickey Pickorita
@Pickorita
Jul 01 2017 00:26
I see
so I would have to write html as well
and this javascript is fine right?
Saif Ur Rahman
@saifsmailbox98
Jul 01 2017 00:26
@Pickorita yes
yes
Nickey Pickorita
@Pickorita
Jul 01 2017 00:26
ok I see
Saif Ur Rahman
@saifsmailbox98
Jul 01 2017 00:26
goodluck :+1:
bye
gn
Nickey Pickorita
@Pickorita
Jul 01 2017 00:26
thanks
hey hold on
Saif Ur Rahman
@saifsmailbox98
Jul 01 2017 00:26
...
Nickey Pickorita
@Pickorita
Jul 01 2017 00:26
what tags should i use to create in html?
sorry
for holding you
Saif Ur Rahman
@saifsmailbox98
Jul 01 2017 00:27
no prob
kumquatfelafel
@kumquatfelafel
Jul 01 2017 00:27
Off as well for now.
Saif Ur Rahman
@saifsmailbox98
Jul 01 2017 00:27
<div> tags or anything you want like <p>, whatever , <h1>, etc
Nickey Pickorita
@Pickorita
Jul 01 2017 00:27
ok
this was my
Saif Ur Rahman
@saifsmailbox98
Jul 01 2017 00:27
just add the attribute id same as in your js
Nickey Pickorita
@Pickorita
Jul 01 2017 00:27
area of a circle
something similar right?
Saif Ur Rahman
@saifsmailbox98
Jul 01 2017 00:28
@Pickorita not on repl.it
codepen :+1:
@Pickorita there are separate sections for HTML, CSS and JS
Nickey Pickorita
@Pickorita
Jul 01 2017 00:28
I know
just wanted to share quickly
sorry for holding you from going to sleep
Saif Ur Rahman
@saifsmailbox98
Jul 01 2017 00:29
as you are using document.getElementById('txtRadius') set id=txtRadius not class
also for other elements.
please check my area of a circle codepen
I can code html/css but I'm having lots of problems with javascript
Saif Ur Rahman
@saifsmailbox98
Jul 01 2017 00:31
I would suggest doing FCC first.
Nickey Pickorita
@Pickorita
Jul 01 2017 00:31
FFC?
Saif Ur Rahman
@saifsmailbox98
Jul 01 2017 00:31
freeCodeCamp
Nickey Pickorita
@Pickorita
Jul 01 2017 00:31
I did
Saif Ur Rahman
@saifsmailbox98
Jul 01 2017 00:31
in feb?
Nickey Pickorita
@Pickorita
Jul 01 2017 00:31
yea
and been learning off of it
for now
practicing html/css mostly
Saif Ur Rahman
@saifsmailbox98
Jul 01 2017 00:32
@Pickorita you need to code everyday
Nickey Pickorita
@Pickorita
Jul 01 2017 00:32
I've been doing that
for html/css
just started javascript
like a month ago
Saif Ur Rahman
@saifsmailbox98
Jul 01 2017 00:32
@Pickorita good
Nickey Pickorita
@Pickorita
Jul 01 2017 00:32
I try to code at least 1h per day
so I practice a lot
but javascript and math are difficult for me
html/css is much easier
Saif Ur Rahman
@saifsmailbox98
Jul 01 2017 00:33
until you learn it.
Nickey Pickorita
@Pickorita
Jul 01 2017 00:33
I'll keep practicing I guess
till I learn it enough to be able to write this code that I need
Saif Ur Rahman
@saifsmailbox98
Jul 01 2017 00:34
You don't know JS
Nickey Pickorita
@Pickorita
Jul 01 2017 00:34
yea not really
free online book series
bye
Nickey Pickorita
@Pickorita
Jul 01 2017 00:34
thank you so much
Saif Ur Rahman
@saifsmailbox98
Jul 01 2017 00:34
:wave:
Nickey Pickorita
@Pickorita
Jul 01 2017 00:34
bye have a good night!
Saif Ur Rahman
@saifsmailbox98
Jul 01 2017 00:34
thanks @Pickorita
CamperBot
@camperbot
Jul 01 2017 00:34
saifsmailbox98 sends brownie points to @pickorita :sparkles: :thumbsup: :sparkles:
:cookie: 119 | @pickorita |http://www.freecodecamp.com/pickorita
Ednor
@ednor
Jul 01 2017 00:36
@ednor Now based on the value of count return Bet or Hold along with count.
@saifsmailbox98 , where ?
CallMeOrange
@EgnaroDev
Jul 01 2017 00:40
Completed Confirm the Ending
function confirmEnding(str, target) {
  var length = target.length;
  str = str.substr(-length);
  if (str == target) {
    return true;
  }
return false;
}

confirmEnding("Bastian", "n");
Ogundele Olumide
@Lumexralph
Jul 01 2017 00:46
@MCTwoDigitZero you can further simplify it
CallMeOrange
@EgnaroDev
Jul 01 2017 00:47
@Lumexralph like this?
function confirmEnding(str, target) {
  var length = target.length;
  str = str.substr(-length);
  if (str == target)  return true;
else if (str !== target) return false;
}

confirmEnding("Bastian", "n");
Ogundele Olumide
@Lumexralph
Jul 01 2017 00:47
@MCTwoDigitZero return str.substr(-length) == target;
CallMeOrange
@EgnaroDev
Jul 01 2017 00:47
I see
Yeah but I want to leave my code alone :D, not looking forward to simplify it
Ogundele Olumide
@Lumexralph
Jul 01 2017 00:48
:smile:
it's your code after all
CallMeOrange
@EgnaroDev
Jul 01 2017 00:55
@Lumexralph Take a look at this
function confirmEnding(str, target) {
   str = str.substring(str.length-1, str.length); return str==target;
}
confirmEnding("Bastian", "n");
function confirmEnding(str, target){ str = str.substring(str.length-1, str.length); return str==target; }
confirmEnding("Bastian", "n");
aRtoo
@artoodeeto
Jul 01 2017 00:56
hi guys help. need help. im testing weather app. if i have this code but its not displaying.
$(document).ready(function()
{
    function weatherData(){
      $.ajax({
        type:'GET',
        url:'api.openweathermap.org/data/2.5/forecast?id=524901&APPID=8bc4ea333a5f2b734509a80ef5ce88d6',
        success: function(data){
          console.log(data.list[1]);
        }
      })
    }
});
Ogundele Olumide
@Lumexralph
Jul 01 2017 00:56
@MCTwoDigitZero or this

function confirmEnding(str, target) {
   return str.substring(str.length-1, str.length) == target;
}
confirmEnding("Bastian", "n");
CallMeOrange
@EgnaroDev
Jul 01 2017 00:56
@Lumexralph Yeah lol, go to FrontEnd chatroom
Ogundele Olumide
@Lumexralph
Jul 01 2017 00:57
@artoodeeto can't see you calling the function weatherData
aRtoo
@artoodeeto
Jul 01 2017 00:58
@Lumexralph ohh. right2. htnak you bro
Ogundele Olumide
@Lumexralph
Jul 01 2017 00:58
@artoodeeto you're welcome
Gurpreet SIngh
@Gurpreet3131
Jul 01 2017 00:58
I have a span element like <span>text here</span>. How can I retrieve the text inside span element
aRtoo
@artoodeeto
Jul 01 2017 00:59
@Lumexralph bro i have an error.
$(document).ready(function()
{
    function weatherData(){
      $.ajax({
        type:'GET',
        url:'api.openweathermap.org/data/2.5/forecast?id=524901&APPID=8bc4ea333a5f2b734509a80ef5ce88d6',
        success: function(data){
          console.log(data.list[1]);
        }
      })
    }
    weatherData();
});
Ogundele Olumide
@Lumexralph
Jul 01 2017 00:59
@Gurpreet3131 use the innerText property of span
@artoodeeto what's the error?
aRtoo
@artoodeeto
Jul 01 2017 01:01
@Lumexralph its that crossoring again bro
@Lumexralph isnt it i just need to change the data type to jsonp??
$(document).ready(function()
{
    function weatherData(){
      $.ajax({
        type:'GET',
        datatype: 'JSONP',
        jsonp: 'JSONP',
        url:'api.openweathermap.org/data/2.5/forecast?id=524901&APPID=8bc4ea333a5f2b734509a80ef5ce88d6',
        success: function(data){
          console.log(data.list[1]);
        }
      })
    }
    weatherData();
});
Ogundele Olumide
@Lumexralph
Jul 01 2017 01:04
@artoodeeto openweather is http, browsers like chrome won't permit, except you use a domain that has https, some use crossorigin.me, can't remember you can check that up
Gurpreet SIngh
@Gurpreet3131
Jul 01 2017 01:04
htmlstr. I have a html code in this string. which contains span elements. Now I want to get the text inside span element and store in into variable spantext. @Lumexralph
any idea on how to do this?
aRtoo
@artoodeeto
Jul 01 2017 01:05
@Lumexralph how bro?? can you send me somelink?? its my firsttime
Ogundele Olumide
@Lumexralph
Jul 01 2017 01:06
@Gurpreet3131 just select is as you do with css, and use a dom method querySelector then access the innerText property containing the text and assign it to the variable
@artoodeeto google it, you should see some results about it, can't vividly remember too
Gurpreet SIngh
@Gurpreet3131
Jul 01 2017 01:06
@Lumexralph the span does not have a class or id
luccifer00
@luccifer00
Jul 01 2017 01:06

Hello everybody!, i am working hard at Random Quote Machine I am at the starting level.... i introduce as i saw in the lessons the following code on the JS area in codepen:

  $(document).ready(function() {
    $("#getMessage").on("click", function(){

      $(".message").html("Here is the message");
    });
  });

i also set the id #getMessage into my button "New Quote" and also i set the class of .message to my div class where the msg should apears... but nothing happens.... i am on the wrong way with something???

aRtoo
@artoodeeto
Jul 01 2017 01:07
@Lumexralph thanks bro
CamperBot
@camperbot
Jul 01 2017 01:07
artoodeeto sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 2010 | @lumexralph |http://www.freecodecamp.com/lumexralph
Gurpreet SIngh
@Gurpreet3131
Jul 01 2017 01:07
And I cannot give it any id or class as i have to do this operation on a lot of span elements
Ogundele Olumide
@Lumexralph
Jul 01 2017 01:07
@Gurpreet3131 doesn't mean, how do you do a css selector, you can give it an id or class then
Gurpreet SIngh
@Gurpreet3131
Jul 01 2017 01:07
for (var i=0;i<lines.length;i++){
        lines[i] = lines[i].innerText;
    }
lines[i]contains the html
now i want it to contain the text instead of html
the html contains only text inside span elements
Ogundele Olumide
@Lumexralph
Jul 01 2017 01:09
@luccifer00 did you click the getMessage button ?
@Gurpreet3131 if you can't give it an id or class, you need to use querySelectorAll do a css selector of where the span element occur on the html, use a loop to get the text of each using innerText
luccifer00
@luccifer00
Jul 01 2017 01:13
@Lumexralph yes! i click the New Quote button ..... i leave the link to my code pen in the question...
Ogundele Olumide
@Lumexralph
Jul 01 2017 01:24
@luccifer00 did you add jQuery library ?
luccifer00
@luccifer00
Jul 01 2017 01:30
mmmm nop @Lumexralph , but i did right now, and i have the same result.... i add the JQuery and the JQuery UI ..... i am testing with the entire code of the exercise, on code pen, and also not respond to the click.... maybe i am missing something similar to adding a library?? :shipit:
CallMeOrange
@EgnaroDev
Jul 01 2017 01:31
@luccifer00 Add jQuery only
luccifer00
@luccifer00
Jul 01 2017 01:32
@Lumexralph sorry... you were right!! when i copy the entire code, i should spearate the Jquery to JS instead stay in Html! thanks
CamperBot
@camperbot
Jul 01 2017 01:32
luccifer00 sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 2011 | @lumexralph |http://www.freecodecamp.com/lumexralph
luccifer00
@luccifer00
Jul 01 2017 01:38
how can i add the box in the middle, as the example link???
anyway, i would like to make first de challenge, and after that stylize it
M-C-Haker
@M-C-Haker
Jul 01 2017 02:01

var string = str.split(" ");

var longest = 0;

var word = null;

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

if (longest < str[i].length) {

        longest = str[i].length;

        word = str[i];

}

}

return word.length;

}

Nvm syntac errors
Nick Janne
@njanne19
Jul 01 2017 02:04
Does anyone see why I'm getting an error saying "Unknown props" when I pass my statelessFunctionalRecipe component in RecipeBox
import React from 'react'
import ReactDOM from 'react-dom'
import ReactBootstrap from 'react-bootstrap'
import { ListGroup } from 'react-bootstrap'
import { ListGroupItem } from 'react-bootstrap'

let statelessFunctionalRecipe = (props) => {
  let source = null;
  if(props.image) {
    source = props.image;
  }
  let ingredients = this.props.ingredients.map((item) => {
    return (<ListGroupItem>{this.props.ingredients[item]}</ListGroupItem>)
  });

  return (
    <div>
    <h1 className ="text-center">{this.props.food}</h1>
    <img src={source}/>
    <ListGroup>
        {ingredients}
    </ListGroup>
    </div>
  );
};

class RecipeBox extends React.Component {
  constructor(props) {
    super(props);
  }
  render() {
    let ingredients = ["Flakes", "Milk", "Butter"];
    let image = "http://assets.simplyrecipes.com/wp-content/uploads/2008/02/baklava-horiz-a-640.jpg"
    return (
      <statelessFunctionalRecipe image={image} food="Baklava" ingredients={ingredients} />
    );
  }
}

ReactDOM.render(<RecipeBox />, document.getElementById('render-target'));
Moisés Man
@moigithub
Jul 01 2017 02:16
this.props doesnt exist inside statelesFunctionalRecipe
u should use the parameter prop instead
also ingredients is an array of strings...
soo when u do map( item .....
item will be a string element from that array like "Flakes"
return (<ListGroupItem>{this.props.ingredients[item]}</ListGroupItem>)
should be
return (<ListGroupItem>{item}</ListGroupItem>)
@njanne19
CallMeOrange
@EgnaroDev
Jul 01 2017 02:37
Hey so I completed repeat a string repeat a string...
function repeatStringNumTimes(str, num) {
  var repeat = [];
  for (var i = 1; i<=num; i++) {
    repeat.push(str);
  }
  return repeat.join('');
}

repeatStringNumTimes("abc", 3);
andrewmparker
@andrewmparker
Jul 01 2017 02:46
https://codepen.io/andrewmparker/pen/xrWbWM why isn't my api working??
Johnny
@jtan3
Jul 01 2017 03:02
@MCTwoDigitZero you don't need a for loop for that problem. You should look up str.repeat().
CallMeOrange
@EgnaroDev
Jul 01 2017 03:03
@jtan3 I know .repeat() already..
Thats like cheating to me
```
function repeatStringNumTimes(str, num) {
  return str.repeat(num);
}

repeatStringNumTimes("abc", 3);
```
Moisés Man
@moigithub
Jul 01 2017 03:04
another way
new Array(3).fill("abc")
// ["abc", "abc", "abc"]
then join
CallMeOrange
@EgnaroDev
Jul 01 2017 03:05
I dont know fill method :p
Leave my code :shipit:
alone
new Array(3).fill("abc") what it does?
fill abc three times?
Moisés Man
@moigithub
Jul 01 2017 03:07
open ur browser devtools.. go to console.. and write that code there
CallMeOrange
@EgnaroDev
Jul 01 2017 03:07
Nah
I see
Only if I knew fill method :p
Joseph
@revisualize
Jul 01 2017 03:10
:wave:
CallMeOrange
@EgnaroDev
Jul 01 2017 03:11
@revisualize :wave:
Hows your wrists?
Nick Janne
@njanne19
Jul 01 2017 03:13
@moigithub I did that and it still doesn't recognize the props
Moisés Man
@moigithub
Jul 01 2017 03:13
show code.. with changes @njanne19
Nick Janne
@njanne19
Jul 01 2017 03:14
@moigithub
import React from 'react'
import ReactDOM from 'react-dom'
import ReactBootstrap from 'react-bootstrap'
import { ListGroup } from 'react-bootstrap'
import { ListGroupItem } from 'react-bootstrap'

let statelessFunctionalRecipe = (props) => {
  let source = null;
  if(props.image) {
    source = props.image;
  }
  let ingredients = props.ingredients.map((item) => {
    return (<ListGroupItem>{item}</ListGroupItem>)
  });

  return (
    <div>
    <h1 className ="text-center">{props.food}</h1>
    <img src={source}/>
    <ListGroup>
        {ingredients}
    </ListGroup>
    </div>
  );
};

class RecipeBox extends React.Component {
  constructor(props) {
    super(props);
  }
  render() {
    let ingredients = ["Flakes", "Milk", "Butter"];
    let image = "http://assets.simplyrecipes.com/wp-content/uploads/2008/02/baklava-horiz-a-640.jpg"
    return (
      <statelessFunctionalRecipe image={ image } food="Baklava" ingredients={ ingredients } />
    );
  }
}

ReactDOM.render(<RecipeBox />, document.getElementById('render-target'));
Assuming I did what you said correctly
jasonrest
@jasonrest
Jul 01 2017 03:18
hey can you guys do me a favor. load this codepen and see if the location and weather map info is correct?
https://codepen.io/jasonrest/pen/mwXZNY/
can you paste whatever you get here.
Joseph
@revisualize
Jul 01 2017 03:18
@MCTwoDigitZero wrecked.
Nick Janne
@njanne19
Jul 01 2017 03:19
@jasonrest
Correct Town , US
72°
moderate rain
Humidity 83%
Your image is messed up tho
jasonrest
@jasonrest
Jul 01 2017 03:19
yeah, i know some kind of issue between pixabay and codepen. but just checking functionality thanks
CallMeOrange
@EgnaroDev
Jul 01 2017 03:22
@revisualize Damn
Hope your wrists will heal back to normal
Joseph
@revisualize
Jul 01 2017 03:24
@MCTwoDigitZero surgery. It will take about a year for things to be back to semi normal.
CallMeOrange
@EgnaroDev
Jul 01 2017 03:25
I see
broken wrists take longer to heal than I thought
Keon Samuel
@keonsam
Jul 01 2017 03:30
only bone I want to break is my ....
ribs
CallMeOrange
@EgnaroDev
Jul 01 2017 03:31
@keonsam Jeez
Keon Samuel
@keonsam
Jul 01 2017 03:31
least useful.
CallMeOrange
@EgnaroDev
Jul 01 2017 03:31
I think only bone I want to break is my arm
I think ribs hurt even worse..
Maybe foot?
Keon Samuel
@keonsam
Jul 01 2017 03:32
like to walk.
Moisés Man
@moigithub
Jul 01 2017 03:32
@njanne19 https://codesandbox.io/s/wAz156oz
component names should be Capitalized
CallMeOrange
@EgnaroDev
Jul 01 2017 03:32
@keonsam skull
Keon Samuel
@keonsam
Jul 01 2017 03:33
try import {Component} from 'react'.
class Name extends Component{}
CallMeOrange
@EgnaroDev
Jul 01 2017 03:35
or... all of your bones
Every single of your bone
Keon Samuel
@keonsam
Jul 01 2017 03:37
Every one lol?
fdemaa
@fdemaa
Jul 01 2017 03:37
so can anyone tell me if im in the right track ? I know its wrong to insert each argument manually , but i was just testing some stuffs

function destroyer(arr) {

var a = Array.from(arguments); 
console.log(a);


var test = arr.filter(function(arr){
  return arr !== a[1] && arr!==a[2] && arr!== a[3];
});

 return test;



 /// return arr;
}

destroyer([1, 2, 3, 1, 2, 3], 3, 2);
I was thinking in use indeof maybe ?
Keon Samuel
@keonsam
Jul 01 2017 03:38
did it ran?
Manish Giri
@Manish-Giri
Jul 01 2017 03:39
@fdemaa make an array out of the list of arguments
then you can filter over arr and keep those elements which are not present in the array you made.
fdemaa
@fdemaa
Jul 01 2017 03:40
@Manish-Giri hi manish! cool man! thanks
CamperBot
@camperbot
Jul 01 2017 03:40
fdemaa sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6163 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Jul 01 2017 03:40
@fdemaa :+1:
Aishvarya Gupta
@aishvarya0502
Jul 01 2017 05:12
If any one can suggest a better way of doing it. Looking for ways to do the same, I think my is not the effective way to do, though it is giving results.

function mutation(arr) {
  arr = arr.map(function(val){
    return val.toLowerCase();
  });

  var subArray = arr[1].split("");

  for(var i = 0 ; i<subArray.length ; i++){
    if(arr[0].indexOf(subArray[i]) !== -1){
      subArray[i] = 1;
    }else{
      subArray[i] = 0;
    }
  }

  if( subArray.reduce(function(prev,current){return prev*current;})){
    return true;
  }else{
    return false;
  }

}

mutation(["Mary", "Aarmy"]);
kumquatfelafel
@kumquatfelafel
Jul 01 2017 05:18
@aishvarya0502 About to try to force myself to fall asleep, but upon immediate glance... there's no need to stick around for subArray[i] = 0. If subarray anything is 0 it's false and we don't need to continue function. And if we deal with false cases in for loop.... do we really need the reduce?
Aishvarya Gupta
@aishvarya0502
Jul 01 2017 05:21
@kumquatfelafel okay;
Pieter Stokkink
@forkerino
Jul 01 2017 05:37
@aishvarya0502 also no need to .split the word. You can use indices on strings as well.
kumquatfelafel
@kumquatfelafel
Jul 01 2017 05:38

There's certain generalized strategies when dealing with these kinds of things......

say there's a bunch of animals, and I want to know whether or not at least one of those animals is a penguin... So I look at each animal individually, and go "nope... nope... not you... not you either...Hey! A penguin!"... and the moment I see that penguin I can stop looking. That's because I know for certain that at least one of those animals is a penguin.

On the other hand, I wouldn't know for certain that none of the animals is a penguin without looking at every animal. After all, maybe one of the animals I haven't looked at is... in fact... a penguin.

You can apply similar concept to code. It's helpful to think about stuff like "are there certain cases when I have to check every "animal"? If so, I should probably make sure that I do! Are there cases when I can stop early? how can I structure my code to make this happen"

Joseph
@revisualize
Jul 01 2017 06:10
cbot
CamperBot
@camperbot
Jul 01 2017 06:10
you called?
Joseph
@revisualize
Jul 01 2017 06:11
Is this channel dead tonight?
Aishvarya Gupta
@aishvarya0502
Jul 01 2017 06:16
@forkerino :+1:
kumquatfelafel
@kumquatfelafel
Jul 01 2017 06:17
Seems that way. Feel like I should sleep, but keep getting dragged back in to writing tongue in cheek solution https://repl.it/JJgY/2 to this https://www.codewars.com/kata/beginner-friendly-uppercase-a-string/train/javascript
Aishvarya Gupta
@aishvarya0502
Jul 01 2017 06:17
@forkerino whats the function specific for that..if any?
kumquatfelafel
@kumquatfelafel
Jul 01 2017 06:19
@aishvarya0502 you can actually just reference the character like string[insert index here].
e.g. "Hi"[0] would give you H.
Aishvarya Gupta
@aishvarya0502
Jul 01 2017 06:20
@kumquatfelafel okay never knew of that...
Aishvarya Gupta
@aishvarya0502
Jul 01 2017 06:24
@kumquatfelafel thanks again :+1: , I need to deep dive in MDN :smile:
CamperBot
@camperbot
Jul 01 2017 06:24
aishvarya0502 sends brownie points to @kumquatfelafel :sparkles: :thumbsup: :sparkles:
:cookie: 417 | @kumquatfelafel |http://www.freecodecamp.com/kumquatfelafel
kumquatfelafel
@kumquatfelafel
Jul 01 2017 06:25
just be aware that string[index] you can get undefined, whereas bad index on charAt you get empty string.
Aishvarya Gupta
@aishvarya0502
Jul 01 2017 06:26
@kumquatfelafel very nice explanation of penguin example..I now think in that manner
Joseph
@revisualize
Jul 01 2017 06:26
array coursion
Aishvarya Gupta
@aishvarya0502
Jul 01 2017 06:26
@kumquatfelafel yup
Joseph
@revisualize
Jul 01 2017 06:27
i think it is better to get undefined
but different objectives declare different results.
Maks Ushakov
@maks-ushakov
Jul 01 2017 06:29

Seems that way. Feel like I should sleep, but keep getting dragged back in to writing tongue in cheek solution https://repl.it/JJgY/2 to this https://www.codewars.com/kata/beginner-friendly-uppercase-a-string/train/javascript

What problem with this?

return str.toUpperCase();
kumquatfelafel
@kumquatfelafel
Jul 01 2017 06:29
@maks-ushakov Far too simple. It must be wrong. :p ;)
Joseph
@revisualize
Jul 01 2017 06:31

@maks-ushakov

function capitalizeEachWord(str) {
   return str.toUpperCase();
}

You have passed all of the tests! :)

Time: 329ms Passed: 106 Failed: 0
worked for me.
kumquatfelafel
@kumquatfelafel
Jul 01 2017 06:34
@maks-ushakov There's nothing wrong with it. I'm writing a really bad solution for the heck of it. :)
It's a sort of late-night time sink until brain goes from nonfunctioning to sleep.
Pieter Stokkink
@forkerino
Jul 01 2017 06:36
@kumquatfelafel where are you?
like, in the world
Maks Ushakov
@maks-ushakov
Jul 01 2017 06:37
Although if you were wanted to write function without standard library it had made sense
Zack
@CrowsVeldt
Jul 01 2017 06:38
@kumquatfelafel @maks-ushakov Sometimes writing a 'bad' solution is more educational than writing a 'good' one. You can learn a lot from stuff like that.
Samer taha
@zoro12
Jul 01 2017 06:39

Hi, I have created a function that searches for a category in a category tree object and returns all the paths for it as an array of strings, please advice how I can improve it ?
the result im getting now is :
["vehicles",["cars","mercedes"],["trucks","mercedes"],["motorcycles","BMW"]]
i need it in one dimesional array like this :
["vehicles","cars","mercedes","trucks","mercedes","motorcycles","BMW"]

here is also a plunker url for the same code im trying t solve :
Click Here
thanks in advance,
please advice.

var categories = {category:"vehicles",children:[
                 {category:"cars",children:[{category:"mercedes",children:[]}]},
                 {category:"trucks",children:[{category:"mercedes",children:[]}]},
                 {category:"motorcycles",children:[{category:"BMW",children:[]}]}
]};


function getnodes(nodes)
{
 var arr=[];
  if (!nodes.children.length) return nodes.category;
  else{
    arr.push(nodes.category);
  for(var i =0 ; i<nodes.children.length ; i++){
      arr.push(getnodes(nodes.children[i]));
  }
  }
     return arr;
}

 var allnodes = getnodes(categories);
 console.log(JSON.stringify(allnodes));
Pieter Stokkink
@forkerino
Jul 01 2017 06:41
@zoro12 use concat instead of push?
arr = arr.concat(getnodes(nodes.children[i]));
kumquatfelafel
@kumquatfelafel
Jul 01 2017 06:42
@forkerino ny, usa. have some... sleep issues though...
Maks Ushakov
@maks-ushakov
Jul 01 2017 06:42
@zoro12 See challenge Steamroller
Samer taha
@zoro12
Jul 01 2017 06:42
@maks-ushakov where to see it ?
@maks-ushakov and what is it ?
Maks Ushakov
@maks-ushakov
Jul 01 2017 06:42
intermediate algorithms
Samer taha
@zoro12
Jul 01 2017 06:42
@forkerino thanks i will try 1 min
CamperBot
@camperbot
Jul 01 2017 06:42
zoro12 sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2802 | @forkerino |http://www.freecodecamp.com/forkerino
Samer taha
@zoro12
Jul 01 2017 06:43
@maks-ushakov thanks
kumquatfelafel
@kumquatfelafel
Jul 01 2017 06:44
My sister's in austria, and I'd probably be in better schedule over there than here at moment :laughing:
Pieter Stokkink
@forkerino
Jul 01 2017 06:44
@kumquatfelafel staring at screens doesn't help me fall asleep at all.
It wakes up my brain
Joseph
@revisualize
Jul 01 2017 06:45
codewars pisses me off.
Manish Giri
@Manish-Giri
Jul 01 2017 06:45
@kumquatfelafel how's the weather up there?
I plan to visit next week.
Samer taha
@zoro12
Jul 01 2017 06:46
@forkerino im getting an empty array when i use cocat instead of push !!
[]
Maks Ushakov
@maks-ushakov
Jul 01 2017 06:47

codewars pisses me off.

Why? Sometime they suggests pretty interesting challenge

Manish Giri
@Manish-Giri
Jul 01 2017 06:47
yeah I'm on this "strings mix" kata
very interesting
kumquatfelafel
@kumquatfelafel
Jul 01 2017 06:47
@Manish-Giri been pretty warm. Was stormish late today. Not sure about next week.
Samer taha
@zoro12
Jul 01 2017 06:48
var categories = {category:"vehicles",children:[
                 {category:"cars",children:[{category:"mercedes",children:[]}]},
                 {category:"trucks",children:[{category:"mercedes",children:[]}]},
                 {category:"motorcycles",children:[{category:"BMW",children:[]}]}
]};


function getnodes(nodes)
{
 var arr=[];
  if (!nodes.children.length) return [nodes.category];
  else{
    arr.concat([nodes.category]);
  for(var i =0 ; i<nodes.children.length ; i++){
      arr.concat([getnodes(nodes.children[i])]);
  }
  }
     return arr;
}

 var allnodes = getnodes(categories);
 console.log(JSON.stringify(allnodes));
arr.concat return [] empty array
Markus Kiili
@Masd925
Jul 01 2017 06:48
@zoro12 arr = arr.concat(...);
Concat returns a new array.
Samer taha
@zoro12
Jul 01 2017 06:49
ok right i will try to fix it
@Masd925 thanks
CamperBot
@camperbot
Jul 01 2017 06:49
zoro12 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4282 | @masd925 |http://www.freecodecamp.com/masd925
Samer taha
@zoro12
Jul 01 2017 06:50
@Masd925 it gave me not correct result also !!
["vehicles",["cars",["mercedes"]],["trucks",["mercedes"]],["motorcycles",["BMW"]]]
instead of
["vehicles","cars","mercedes","trucks","mercedes","motorcycles","BMW"]
Pieter Stokkink
@forkerino
Jul 01 2017 06:52
@zoro12 don't put the argument to concat in [ ]
it is already an array, so nested array will be the result
Samer taha
@zoro12
Jul 01 2017 06:53
@forkerino ok i will see it in plunker 1 min
Pieter Stokkink
@forkerino
Jul 01 2017 06:53

arr = arr.concat(getnodes(nodes.children[i]));

like I said earlier

Maks Ushakov
@maks-ushakov
Jul 01 2017 06:55
Does codewars have FreeCodeCamp clan?
Samer taha
@zoro12
Jul 01 2017 06:56
@forkerino thank you i have better result now but i have to remove duplicate nodes ```
CamperBot
@camperbot
Jul 01 2017 06:56
zoro12 sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:warning: zoro12 already gave forkerino points
Samer taha
@zoro12
Jul 01 2017 06:56
["vehicles","cars","mercedes","trucks","mercedes","motorcycles","BMW"]
how i remove duplicated nodes like mercedes ?
Maks Ushakov
@maks-ushakov
Jul 01 2017 06:57
filter() function
Kamal
@kpbro
Jul 01 2017 06:58
can i hide my weather api key on codepen such that it is not visible in code?
Samer taha
@zoro12
Jul 01 2017 06:58
i will try filter but i cant predict how it will work in a resursion
@maks-ushakov thanks
CamperBot
@camperbot
Jul 01 2017 06:58
zoro12 sends brownie points to @maks-ushakov :sparkles: :thumbsup: :sparkles:
:cookie: 368 | @maks-ushakov |http://www.freecodecamp.com/maks-ushakov
Samer taha
@zoro12
Jul 01 2017 06:59
@camperbot hi how to send you those points ?
Maks Ushakov
@maks-ushakov
Jul 01 2017 06:59
just mentioned somebdy and say 'thanks'
You have already done it
Pieter Stokkink
@forkerino
Jul 01 2017 07:01
@kpbro I don't think so. Maybe on codepen pro, but that is a paid service.
kumquatfelafel
@kumquatfelafel
Jul 01 2017 07:01
@forkerino true. Though a lot of it is just returning from visiting family so getting over time zone difference.
will be back to almost normal soon probably :p
Pieter Stokkink
@forkerino
Jul 01 2017 07:02
@zoro12 I don't think .filter will cause problems in the recursion. Just do it in the place where you return the array.
Samer taha
@zoro12
Jul 01 2017 07:02
@forkerino ok i will try
Pieter Stokkink
@forkerino
Jul 01 2017 07:02
@kumquatfelafel jet lag can be horrible. And it gets worse with age!
Samer taha
@zoro12
Jul 01 2017 07:03
@forkerino i have weak experience with recursion its hard to grasp at first
kumquatfelafel
@kumquatfelafel
Jul 01 2017 07:05
@forkerino yeeeep.
Sweet Coding :)
@SweetCodingInc
Jul 01 2017 07:06
@zoro12 You could use reduce as well
var arr = ["vehicles","cars","mercedes","trucks","mercedes","motorcycles","BMW"];

var result = arr.reduce( (f, c) => {
  if(!f.includes(c)){
    f.push(c);
  }
  return f;
}, []);

console.log(arr.toString()); //vehicles,cars,mercedes,trucks,mercedes,motorcycles,BMW
console.log(result.toString()); // vehicles,cars,mercedes,trucks,motorcycles,BMW
Pieter Stokkink
@forkerino
Jul 01 2017 07:07
@SweetCodingInc @zoro12 or Set!
return [...new Set(arr)];
Samer taha
@zoro12
Jul 01 2017 07:07
@SweetCodingInc yes thanks i already used filter like this
CamperBot
@camperbot
Jul 01 2017 07:07
:cookie: 51 | @sweetcodinginc |http://www.freecodecamp.com/sweetcodinginc
zoro12 sends brownie points to @sweetcodinginc :sparkles: :thumbsup: :sparkles:
Sweet Coding :)
@SweetCodingInc
Jul 01 2017 07:07
@forkerino : Yo! Even that works too :)
Samer taha
@zoro12
Jul 01 2017 07:07
arr = arr.filter (function (value, index, array) { 
    return array.indexOf (value) == index;
});
Pieter Stokkink
@forkerino
Jul 01 2017 07:07
@zoro12 :+1:
Sweet Coding :)
@SweetCodingInc
Jul 01 2017 07:07
@zoro12 : :+1:
Samer taha
@zoro12
Jul 01 2017 07:08
im getting correct results now great thanks guys !!
Pieter Stokkink
@forkerino
Jul 01 2017 07:08
awesome
Samer taha
@zoro12
Jul 01 2017 07:08
["vehicles","cars","mercedes","trucks","motorcycles","BMW"]
you can chose a car from the array as a gift for helping me lol
Pieter Stokkink
@forkerino
Jul 01 2017 07:09
:P
Sweet Coding :)
@SweetCodingInc
Jul 01 2017 07:09
@zoro12 :get me vehicles:P
Samer taha
@zoro12
Jul 01 2017 07:10
@SweetCodingInc take all the array for free :smile:
Sweet Coding :)
@SweetCodingInc
Jul 01 2017 07:10
@zoro12 :D
Samer taha
@zoro12
Jul 01 2017 07:11
@forkerino special thanks for @forkerino @forkerino @forkerino @forkerino @forkerino
CamperBot
@camperbot
Jul 01 2017 07:11
zoro12 sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:warning: zoro12 already gave forkerino points
kumquatfelafel
@kumquatfelafel
Jul 01 2017 07:16
cbot
CamperBot
@camperbot
Jul 01 2017 07:16
you called?
kumquatfelafel
@kumquatfelafel
Jul 01 2017 07:16
Stop eating people's brownies!
Pieter Stokkink
@forkerino
Jul 01 2017 07:16
about @camperbot
CamperBot
@camperbot
Jul 01 2017 07:16
:star2: 3358 | @camperbot |http://www.freecodecamp.com/camperbot
Pieter Stokkink
@forkerino
Jul 01 2017 07:16
brownie hog
about @forkerino
CamperBot
@camperbot
Jul 01 2017 07:18
:star2: 2802 | @forkerino |http://www.freecodecamp.com/forkerino
Pieter Stokkink
@forkerino
Jul 01 2017 07:18
I'm closing in
kumquatfelafel
@kumquatfelafel
Jul 01 2017 07:19
I... I'm sorry. I just have to thank @camperbot for providing all this info about other people....
CamperBot
@camperbot
Jul 01 2017 07:19
kumquatfelafel sends brownie points to @camperbot :sparkles: :thumbsup: :sparkles:
:star2: 3359 | @camperbot |http://www.freecodecamp.com/camperbot
Pieter Stokkink
@forkerino
Jul 01 2017 07:19
:joy:
kumquatfelafel
@kumquatfelafel
Jul 01 2017 07:21
Alright. Starting to feel "sleepable". Night
Pieter Stokkink
@forkerino
Jul 01 2017 07:21
:wave:
aRtoo
@artoodeeto
Jul 01 2017 07:32
bros need help. why is it when use jsonp i have an error. but when i delete it it gives me the data. isnt it we need to use jsonp if the API is using http and not htpps? heres the code.
$(document).ready(function()
{
      function weatherData(){
      $.ajax({
        dataType: "jsonp",
        jsonp: 'jsonp',
        /*dataType: "jsonp",
        jsonp: 'jsonp',

        when i put this JSONP i get an error.
        but when i delete it i get the data fine.
        isnt it JSONP suppose to be needed if you have an API that gets HTTP and not HTPPS.
        the error is this "Uncaught SyntaxError: Unexpected token :"

        */
        type:'GET',
        url:'http://api.openweathermap.org/data/2.5/forecast?id=524901&APPID=8bc4ea333a5f2b7345409a80ef5ce88d6',
        success: function(data){
          console.log(data.list);
        }
      })
    }
    weatherData();

});
alpox
@alpox
Jul 01 2017 07:34
@artoodeeto no, you need jsonp when the server doesnt allow cross origin ajax requests.
@artoodeeto jsonp doesnt help you with https. You wont be able to use openweather at all on codepen because openweather has no free plan for https
onikroo
@onikroo
Jul 01 2017 07:36
Hi, wondering if anyone can give me a pointer on the Caesars Cipher..

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

var newStr;
for (i=0;i<str.length;i++) { var oldStr = str; var letCode = oldStr.charCodeAt(i); if (letCode<=77) { newStr = oldStr.replace(letCode,String.fromCharCode(letCode+13)); } else if (letCode>77) {
newStr = oldStr.replace(oldStr.charAt(i),String.fromCharCode(letCode+19));
}

}
return newStr;
} ```

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

  var newStr;
for (i=0;i<str.length;i++) {
  var oldStr = str;
  var letCode = oldStr.charCodeAt(i);
  if (letCode<=77) {
   newStr = oldStr.replace(letCode,String.fromCharCode(letCode+13));
  } else if (letCode>77) {
   newStr = oldStr.replace(oldStr.charAt(i),String.fromCharCode(letCode+19));
  }

}
  return newStr;
}
Actually wait, I have just seen it.
Am overwriting newStr each loop… derp
onikroo
@onikroo
Jul 01 2017 07:52
So my first if condition isnt being applied. I cannot see why.

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

  var oldStr = str;
    for (i=0;i<str.length;i++) {
      var letCode = oldStr.charCodeAt(i);
      if (letCode>=65 && letCode<=77) {
         oldStr = oldStr.replace(oldStr.charAt(i),String.fromCharCode(letCode+13));
      } else if (letCode>=78 && letCode<=90) {
         oldStr = oldStr.replace(oldStr.charAt(i),String.fromCharCode(letCode+19));
      }  
    }
  return oldStr.toUpperCase();
}

rot13("SERR PBQR PNZC");
Samer taha
@zoro12
Jul 01 2017 07:55
its me again
onikroo
@onikroo
Jul 01 2017 07:55
I get FEEE CODR CAMP as the result, so seems else if statement works great.
Samer taha
@zoro12
Jul 01 2017 07:56
Now im trying to write a function that take a tree of categories and search item and return only paths belong to that item but im again getting not exact results ...



(function(){
  'use strict';

window.onload = function(){

var getPathsOf = function(node,srch){ 
    var arr=[];

    if (node.category === srch) return srch;
    else if (!node.children.length) return node.category+'#';
    else{
    for(var i=0 ; i < node.children.length ; i++)
    arr=arr.concat(node.category+'/'+getPathsOf(node.children[i],srch));
    }
    arr = arr.filter(function(item){ return !item.endsWith("#");});
    return arr;
  }

var categories = {category:"vehicles",children:[
                 {category:"cars",children:[{category:"mercedes",children:[]}]},
                 {category:"trucks",children:[{category:"mercedes",children:[]}]},
                 {category:"motorcycles",children:[{category:"BMW",children:[]}]}
]};  


var srchpath = getPathsOf(categories,'mercedes');
   // srchpath = srchpath.filter(function(item){ return !item.endsWith("#");});
    document.getElementById("paths").innerHTML= JSON.stringify(srchpath);

 srchpath = getPathsOf(categories,'BMW');
 //srchpath = srchpath.filter(function(item){ return !item.endsWith("#");});
 document.getElementById("paths").innerHTML += '<br>'+JSON.stringify(srchpath);

  getPathsOf(categories,'mercedes');
 }; //window.onload

})();
you can see it also in plunker at http://plnkr.co/edit/YZGll8?p=preview
this is the html indexx.html im using ...
<!DOCTYPE html>
<html>

  <head>
    <script src="script.js"></script>
  </head>

  <body>
    <h1>Hello Plunker!</h1>
    <p id="cats">my solution</p>
    <p id="debug"></p>
    <p id="paths"></p>
    </body>

</html>
the resut im getting now is as follows
["vehicles/cars/mercedes","vehicles/trucks/mercedes","vehicles/"]
["vehicles/","vehicles/","vehicles/motorcycles/BMW"]

the wanted result for mercedes in the first line should be ...
["vehicles/cars/mercedes","vehicles/trucks/mercedes"]
for "BMW" search item should be only one path as in the tree....
["vehicles/motorcycles/BMW"]
Samer taha
@zoro12
Jul 01 2017 08:01
any idea whats iam doing wrong with this recursive function causing incorrect results to be returned ?
by the way im using the # only to sign the paths that ended without finding the wanted search item socalled "srch" so later before returning the end result i filter all the # paths from the array ...
Samer taha
@zoro12
Jul 01 2017 08:10
anybody is awake in the other side of the globe ?
Samer taha
@zoro12
Jul 01 2017 08:18
the question in my mind now why filter is not removing all nodes that end with # instead it remove part of the item !!
arr = arr.filter(function(item){ return !item.endsWith("#");});
Manish Giri
@Manish-Giri
Jul 01 2017 08:30
@zoro12 the problem is not in the filter line
must be somewhere else
Samer taha
@zoro12
Jul 01 2017 08:30
@Manish-Giri yes maybe
my brain is in infinite loop now
@zoro12
filter works correctly
Samer taha
@zoro12
Jul 01 2017 08:33
@Manish-Giri yes i tested it also
@Manish-Giri if you comment out the filter statement the line before return arr; you will get full arrays like so ...
["vehicles/cars/mercedes","vehicles/trucks/mercedes","vehicles/motorcycles/#"]
["vehicles/cars/#","vehicles/trucks/#","vehicles/motorcycles/BMW"]
the filter is filtering out only part of the items like vehicles/motorcycles/# will make it vehicles/ !!!
its not removing all the item as we need
Manish Giri
@Manish-Giri
Jul 01 2017 08:44
I tried out your second array, it works fine
It returned only the BMW item
@zoro12
Samer taha
@zoro12
Jul 01 2017 08:45
@Manish-Giri where you tried it ? in plunker you have a link ?
Manish Giri
@Manish-Giri
Jul 01 2017 08:45
In jsbin
Same link I posted earlier
Instead of my array I used the second one you had
Samer taha
@zoro12
Jul 01 2017 08:46
yes but it acts differently when called in a recursive function
Manish Giri
@Manish-Giri
Jul 01 2017 08:47
Then it must be a bug with the function definition
Because filter is working fine
Samer taha
@zoro12
Jul 01 2017 08:48
yes thats what im trying to solve i know the problem is not in the filter itself
how do i do the type writer effect
anyone ?
Miljan Grcic
@Nightimer
Jul 01 2017 09:17
Hellou
Lets say i have this aray [item1, item2, item3, item4, item5, item6], is it possible to slice that array and get lets say [item3, item4,item5,item6, item1]
like start slice from middle of array, slice it to end, and then start again from beggining
Alan Alickovic
@alan2207
Jul 01 2017 09:28
@Nightimer do you mean something like binary search?
to slice it until one element is left?
gchab
@gchab
Jul 01 2017 09:29

Hello, I am blocked in the challeng mutation and i could use a hand. Here is my code:
'''
function mutation(arr) {
var arrLower = arr.toLocaleString().toLowerCase().split(",");
var teste = arrLower[0];
var test= arrLower[1];

for (var i=0; i<arrLower[1].length; i++) {
if (teste.indexOf(test[i])<0) {
return false;
}
else { return true;
}
}
}
'''
it works for everything, just the exemple "hello", "hey" comes back as true.. thx in advance
mutation(["hello", "hey"]);

CamperBot
@camperbot
Jul 01 2017 09:29
:bulb: to format code use backticks! ``` more info
Miljan Grcic
@Nightimer
Jul 01 2017 09:39
@alan2207 No no. Say i have array with number from 1 to 30, so [1,2,3, bla bla 30], slice(start position 15, end position 30, then again up untill lets say 7)
If you understand what i mean
Zyberg
@Zyberg
Jul 01 2017 09:40
@gchab your loop doesn't work as it is supposed to! You are returning false after checking just one value (the first letter). Try writing it like this:
for (var i = 0; i < arrLower[1].length; i++){
if (teste.indexOf(test[i])<0) {
return false;
}
}
// when whole array is checked, return true - it didn't see any missmatches
return true;
Loris Hanck
@Pouletcoq
Jul 01 2017 09:41
Hello I need help for my tic tac toe project :D I don't know how to stop the hover function when the player has finished to play :/ https://codepen.io/Pouletcoq/pen/weyZro
Zyberg
@Zyberg
Jul 01 2017 09:42
@Pouletcoq maybe try adding a boolean flag? isFinished initialy would be false. Something like that in pseudocode:
//beginning of the file
var isFinished = false;

//...
if (!isFinished){
onhover(...);
}
//...

//when game is finished
isFinished = true;
Loris Hanck
@Pouletcoq
Jul 01 2017 09:43
@Zyberg Yep i'm gonna try thx :D
CamperBot
@camperbot
Jul 01 2017 09:43
pouletcoq sends brownie points to @zyberg :sparkles: :thumbsup: :sparkles:
:cookie: 266 | @zyberg |http://www.freecodecamp.com/zyberg
gchab
@gchab
Jul 01 2017 09:45
@Zyberg Indeed, thanks you a lot
CamperBot
@camperbot
Jul 01 2017 09:45
gchab sends brownie points to @zyberg :sparkles: :thumbsup: :sparkles:
:cookie: 267 | @zyberg |http://www.freecodecamp.com/zyberg
Alan Alickovic
@alan2207
Jul 01 2017 10:06
@Nightimer yes, i understand, but why would you do that, to find particular item in array, or something else?
Miljan Grcic
@Nightimer
Jul 01 2017 10:11
@alan2207
var weekDays = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
I need to display "Next five days"
Alan Alickovic
@alan2207
Jul 01 2017 10:13
@Nightimer i see, but you need to also rotate days, so if starting from Fri, you need to return Sat, Sun etc...
am i correct?
Miljan Grcic
@Nightimer
Jul 01 2017 10:13
So if today is Wed i need new array with [Thu Fri Say Sun Mon Tue]
@alan2207 Exactly
Alan Alickovic
@alan2207
Jul 01 2017 10:13
@Nightimer i need a moment to solve it myself
or at least try
Miljan Grcic
@Nightimer
Jul 01 2017 10:19
@alan2207 Be my guest :D
Alan Alickovic
@alan2207
Jul 01 2017 10:20
@Nightimer i got it
Muhammad Hasham
@MohammadHasham
Jul 01 2017 10:20
any react guy here?
Alan Alickovic
@alan2207
Jul 01 2017 10:21
function returnNextFiveDays(today) {
    var weekDays = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];

    var todayIndex = weekDays.indexOf(today);


    return weekDays.slice(todayIndex + 1).concat(weekDays.slice(0, todayIndex))
}

console.log(returnNextFiveDays('Fri'))

// will log following:
//[ 'Sat', 'Sun', 'Mon', 'Tue', 'Wed', 'Thu' ]
@Nightimer check it out
Diego Mayer
@Chrono79
Jul 01 2017 10:28
@alan2207 shouldn't that function return only 5 days?
Samer taha
@zoro12
Jul 01 2017 10:29
@Manish-Giri Hi i solved it

(function(){
  'use strict';

window.onload = function(){

var getPathsOf = function(node,srch){ 
    var arr=[];

    if (node.category === srch) return srch;
    if (!node.children.length) return node.category+'#';

    for(var i=0 ; i < node.children.length ; i++)
    arr=arr.concat(node.category+'/'+getPathsOf(node.children[i],srch));

    console.log('before'+JSON.stringify(arr));
    arr = arr.filter(function(item){ return  !(item.endsWith("#") && item.startsWith("vehicles"))});
    console.log('after'+JSON.stringify(arr));
    return arr;
  }

var categories = {category:"vehicles",children:[
                 {category:"cars",children:[{category:"mercedes",children:[]}]},
                 {category:"trucks",children:[{category:"mercedes",children:[]}]},
                 {category:"motorcycles",children:[{category:"BMW",children:[]}]}
]};  

var categories1 = {category:"vehicles",children:[
                 {category:"cars",children:[{category:"mercedes",children:[]}]},
                 {category:"motorcycles",children:[{category:"BMW",children:[]}]}
]};  


var srchpath = getPathsOf(categories,'cars');
   // srchpath = srchpath.filter(function(item){ return !item.endsWith("#");});
    document.getElementById("paths").innerHTML= JSON.stringify(srchpath);
 /*
 srchpath = getPathsOf(categories,'BMW');
 //srchpath = srchpath.filter(function(item){ return !item.endsWith("#");});
 document.getElementById("paths").innerHTML += '<br>'+JSON.stringify(srchpath);
 */
  //getPathsOf(categories,'mercedes');
 }; //window.onload

})();
Alan Alickovic
@alan2207
Jul 01 2017 10:32
@Nightimer yes, i was not paying attention
function returnNextFiveDays(today) {
    var weekDays = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];

    var todayIndex = weekDays.indexOf(today);


    return weekDays.slice(todayIndex + 1).concat(weekDays.slice(0, todayIndex)).slice(0, 5)
}

console.log(returnNextFiveDays('Sat'))

// will return:
//[ 'Sun', 'Mon', 'Tue', 'Wed', 'Thu' ]
there you go
Diego Mayer
@Chrono79
Jul 01 2017 10:33
:+1:
Alan Alickovic
@alan2207
Jul 01 2017 10:34
@Chrono79 yes, but what happens when the day is 'Sun', then error occurs, so i had to slice the whole array in 5
because index is 0, so 0 - 1 becomes -1 which is invalid index
Diego Mayer
@Chrono79
Jul 01 2017 10:34
@alan2207 You're right, I didn't test Sun
Just go into JS
I am not sure that can work based on my current code
Alan Alickovic
@alan2207
Jul 01 2017 10:37
@Nightimer you can use openweathermap's api to get forecast for several days
no need to do all that stuff
Miljan Grcic
@Nightimer
Jul 01 2017 10:39
@alan2207 Forgot to say thanks for solution :clap: I will check that API, but i kinda wanted to go "hard way" and do it all myself
CamperBot
@camperbot
Jul 01 2017 10:39
nightimer sends brownie points to @alan2207 :sparkles: :thumbsup: :sparkles:
:cookie: 477 | @alan2207 |http://www.freecodecamp.com/alan2207
heroiczero
@heroiczero
Jul 01 2017 10:40
codepen does not accept http request now. they just accept https://. see: https://forum.freecodecamp.org/t/local-weather-api-for-people-stuck-because-of-the-https-request/50274 for more detail. Darksky only does minutely and hourly. source: https://darksky.net/dev/docs/forecast
@Nightimer
Jerard Delrosario
@jrardd
Jul 01 2017 10:42

Hi guys I am also working on weather forecast. I'm able to get my current coordinates with geolocation, but I'm not sure if I am calling OpenWeatherMap's API correctly... Can someone tell me what I'm doing wrong? :(

https://codepen.io/jrard/pen/ZyxQXr?editors=1011

heroiczero
@heroiczero
Jul 01 2017 10:43
@jrardd check :point_up: July 1, 2017 6:40 AM openweatherapi does not work since you cant do it in http anymore in codepen
Alan Alickovic
@alan2207
Jul 01 2017 10:43
@Nightimer i would advice you to develop your apps locally on your machine, then publish it via github-pages
Jerard Delrosario
@jrardd
Jul 01 2017 10:43
@heroiczero Seriously? Do I have to pay for Darksky API?
heroiczero
@heroiczero
Jul 01 2017 10:44
@jrardd no just read it you can use what they used
@jrardd Darksky is free just have to sign up
Jerard Delrosario
@jrardd
Jul 01 2017 10:45
@heroiczero Oh! Ok lol thanks :)
CamperBot
@camperbot
Jul 01 2017 10:45
jrardd sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
:star2: 1442 | @heroiczero |http://www.freecodecamp.com/heroiczero
shivam gupta
@shivamg11000
Jul 01 2017 10:50
Hey when would use of const be suggested
using const or let with JSX
Ogundele Olumide
@Lumexralph
Jul 01 2017 10:51
@shivamg11000 if you're not going to change the value of the variable or you intend not assigning another value to the variable const is good for that purpose
teevik
@teevik
Jul 01 2017 10:52
Const should work for JSX
Alan Alickovic
@alan2207
Jul 01 2017 10:53
yes you need to wrap any javascript code in {}
Jerard Delrosario
@jrardd
Jul 01 2017 11:15

Hey guys, if anyone has time, could you look at my code and tell me if my variables "posx" and "posy" are functioning as global variables? I tried referring them in a function and assigning them a value. But when I call them in a different function, they are 'undefined'.

https://codepen.io/jrard/pen/ZyxQXr?editors=1011

Alan Alickovic
@alan2207
Jul 01 2017 11:21
@jrardd they are not global, they are local within the function that runs when the document is loaded
if the function you are calling them with is outside this function posx and posy will be undefined
Jerard Delrosario
@jrardd
Jul 01 2017 11:25
@alan2207 All of my functions are within the $(document).ready(function{}) if that's what you're referring to?
Alan Alickovic
@alan2207
Jul 01 2017 11:26
yes, then you could pretend they are global
where do you get value of undefined? @jrardd
Jerard Delrosario
@jrardd
Jul 01 2017 11:27
@alan2207 I tested by using console.log(posx + " / " + posy); in random spots around the document.ready function and they were all undefined
teevik
@teevik
Jul 01 2017 11:28
@jrardd The functions you use for sucess on ajax are asynch
Mikail Şeremet
@MikailSeremet
Jul 01 2017 11:28
becuase they have no vaule there
Value*
it is only inside of document ready funcion
and there is no value you defined at that position
Alan Alickovic
@alan2207
Jul 01 2017 11:30
@jrardd you are running your success function after console.log(posx + " / " + posy);
Jerard Delrosario
@jrardd
Jul 01 2017 11:30
@MikailSeremet I assigned them a value in one of the functions that run first. At least that's what I wanted to do.. lol
Alan Alickovic
@alan2207
Jul 01 2017 11:30
so at that time the values are undefined @jrardd
i mean getWeather function
Mikail Şeremet
@MikailSeremet
Jul 01 2017 11:30
you cant change the global value inside a function
if you declare with a value you
can see
like this
var posx = 0;
var posy = 1;
Alan Alickovic
@alan2207
Jul 01 2017 11:31
he can by ommiting var keyword
Mikail Şeremet
@MikailSeremet
Jul 01 2017 11:31
yea
Alan Alickovic
@alan2207
Jul 01 2017 11:33
i think the problem is that he is logging console.log(posx + " / " + posy); before the success function from above set the values of posx and posy, so that results in values of undefined
teevik
@teevik
Jul 01 2017 11:33
navigator.geolocation.getCurrentPosition(success, error); success gets run once you the browser gets run once browser gets location, while the rest of the program continnues
It's asynch
jasonrest
@jasonrest
Jul 01 2017 11:34
can you guys see the background photo on this pen?
https://codepen.io/jasonrest/pen/mwXZNY/
teevik
@teevik
Jul 01 2017 11:34
So posx and posy won't be set because "success" function has not ran
Alan Alickovic
@alan2207
Jul 01 2017 11:35
@teevik that is right
Mikail Şeremet
@MikailSeremet
Jul 01 2017 11:36
yea good explanation
Alan Alickovic
@alan2207
Jul 01 2017 11:36
@jasonrest yes
jasonrest
@jasonrest
Jul 01 2017 11:36
@alan2207 Thanks
CamperBot
@camperbot
Jul 01 2017 11:36
jasonrest sends brownie points to @alan2207 :sparkles: :thumbsup: :sparkles:
:cookie: 478 | @alan2207 |http://www.freecodecamp.com/alan2207
Jerard Delrosario
@jrardd
Jul 01 2017 11:37
@teevik Dang now I'm confused lol. So basically what you're saying is I just have to learn what order everything is running in, and fix it, and then my variables will be global?
I mean, will be set**
before my API call
Diego Mayer
@Chrono79
Jul 01 2017 11:38
@jasonrest yes, add the temp unit
jasonrest
@jasonrest
Jul 01 2017 11:38
@Chrono79 temp unit?? you mean c or f
Mikail Şeremet
@MikailSeremet
Jul 01 2017 11:39
@jasonrest yes mate and now you can add a c to f switcher
Diego Mayer
@Chrono79
Jul 01 2017 11:39
@jasonrest yes
Mikail Şeremet
@MikailSeremet
Jul 01 2017 11:39
to f to c
jasonrest
@jasonrest
Jul 01 2017 11:39
@MikailSeremet @Chrono79 right. yes working on it now. I was just having some issues where only I could see the background pic for some reason. but changed it to http. seems ok now. Thanks
CamperBot
@camperbot
Jul 01 2017 11:39
jasonrest sends brownie points to @mikailseremet and @chrono79 :sparkles: :thumbsup: :sparkles:
:cookie: 278 | @mikailseremet |http://www.freecodecamp.com/mikailseremet
:star2: 4451 | @chrono79 |http://www.freecodecamp.com/chrono79
Alan Alickovic
@alan2207
Jul 01 2017 11:40
you are logging console.log(posx + " / " + posy); synchronously, so the values of posx and posy will not be yet set to their values. this is why you are getting values of undefined
Jerard Delrosario
@jrardd
Jul 01 2017 11:41
Well anyways thanks @MikailSeremet @alan2207 and @teevik for helping me out
CamperBot
@camperbot
Jul 01 2017 11:41
jrardd sends brownie points to @mikailseremet and @alan2207 and @teevik :sparkles: :thumbsup: :sparkles:
:cookie: 184 | @teevik |http://www.freecodecamp.com/teevik
:cookie: 279 | @mikailseremet |http://www.freecodecamp.com/mikailseremet
:cookie: 479 | @alan2207 |http://www.freecodecamp.com/alan2207
Jerard Delrosario
@jrardd
Jul 01 2017 11:42
Oh @teevik so.. they actually aren't 'undefined' then? Lol
Well I'll just try to figure it out. Don't wanna waste anymore of your time appreciate the help
luccifer00
@luccifer00
Jul 01 2017 11:43
hi there! i can not find any .json link for the random quote machine...., any tip where i can search?
Mikail Şeremet
@MikailSeremet
Jul 01 2017 11:43
@jrardd they are defined but their values are not yet set tbh :)
@luccifer00 you dont have to use any api for that challange you can set the values yourself inside the js too
Diego Mayer
@Chrono79
Jul 01 2017 11:45
@luccifer00 most people use forismatic
Alan Alickovic
@alan2207
Jul 01 2017 11:45
@jrardd undefined and not defined is not the same
Saif Ur Rahman
@saifsmailbox98
Jul 01 2017 11:45
@luccifer00 you can create your own too, http://myjson.com/.
luccifer00
@luccifer00
Jul 01 2017 11:46
i just find http://quotes.rest/qod.json , i am going to test with that.... i hope not find any problem whit the http or https that i read before....
jasonrest
@jasonrest
Jul 01 2017 11:47
@luccifer00 I'm in no position to offer advice but, I would use the api method as it helped prepare me for the next project.
The quote machine api was rough but when I got to the weather api, I had a much better understanding of what was going on.
luccifer00
@luccifer00
Jul 01 2017 11:48
@jasonrest i hope also to understanding better , by now, i amd follow step by step the method of freecodecamp at that part!
Diego Mayer
@Chrono79
Jul 01 2017 11:50
@luccifer00 it works with https too
Ogundele Olumide
@Lumexralph
Jul 01 2017 11:50
@Chrono79 you got some lil time for an interesting stuff?
Diego Mayer
@Chrono79
Jul 01 2017 11:50
for now...
Ogundele Olumide
@Lumexralph
Jul 01 2017 11:51
maybe not so interesting, it's a codewars challenge
Diego Mayer
@Chrono79
Jul 01 2017 11:51
shoot
Ogundele Olumide
@Lumexralph
Jul 01 2017 11:51
@Chrono79 i'll PM you
Markus Kiili
@Masd925
Jul 01 2017 11:51
:ear:
Diego Mayer
@Chrono79
Jul 01 2017 11:51
@Masd925 good (probably not) morning
Markus Kiili
@Masd925
Jul 01 2017 11:52
Morning
Ogundele Olumide
@Lumexralph
Jul 01 2017 11:55
@Masd925 oh.... let me bring it here then
@Masd925 Good Morning
Kelechi Chinaka
@ke1echi
Jul 01 2017 12:03
hi guys :wave:
Ogundele Olumide
@Lumexralph
Jul 01 2017 12:04
@kelechichinaka Bro
Kelechi Chinaka
@ke1echi
Jul 01 2017 12:04
morning @Lumexralph
Stephen James
@sjames1958gm
Jul 01 2017 12:04
@kelechichinaka :wave:
Kelechi Chinaka
@ke1echi
Jul 01 2017 12:06
i want to ask the word 'native' does it refer to js objects like String, Array etc...pls throw more light
Stephen James
@sjames1958gm
Jul 01 2017 12:08
@kelechichinaka native generally means javascript before you load any libraries. It is not a specific term sort of like vanillas js.
Types and functions provided by the javascript engine.
Ogundele Olumide
@Lumexralph
Jul 01 2017 12:08
@kelechichinaka depends on the context, where the word native is coming from
@sjames1958gm so native is relative to VanillaJS ?
Kelechi Chinaka
@ke1echi
Jul 01 2017 12:09
those it refer to pure old js @sjames1958gm @Lumexralph
Ogundele Olumide
@Lumexralph
Jul 01 2017 12:10
or should I say analogous @sjames1958gm
Kelechi Chinaka
@ke1echi
Jul 01 2017 12:11
pls used word i can relate to :smile: @Lumexralph
Stephen James
@sjames1958gm
Jul 01 2017 12:11
native and vanilla probably mean the same thing.
But, if you are running in the browser are the browser APIs native? Running in node are the node APIs native?
Ogundele Olumide
@Lumexralph
Jul 01 2017 12:11
@kelechichinaka with what @sjames1958gm said it's not really PureJS/VanillaJS. it's the javascript code without any library
@sjames1958gm Browser API are from the host environment @kelechichinaka e.g browser
Kelechi Chinaka
@ke1echi
Jul 01 2017 12:12
ok i get it now
i dont think would call the APIs native @sjames1958gm
Stephen James
@sjames1958gm
Jul 01 2017 12:13
VanillaJS includes the browser APIs in its definition of vanilla.
Ogundele Olumide
@Lumexralph
Jul 01 2017 12:14
meaning VanillaJS can be native or not, right? @sjames1958gm
Pethaf
@Pethaf
Jul 01 2017 12:20
So, I spent yesterday trying to get Angular running.
Didn't work.
Wondering if it is wort the effort.
Markus Kiili
@Masd925
Jul 01 2017 12:23
@Pethaf I work with angular and it never works on the first try. Always something missing.
Pulkit Valecha
@PulkitValecha
Jul 01 2017 12:27
@PulkitValecha
Guys how did you learn about using the java script or jquery for animations like when i click something it should automatically scroll down
I did not find much of this here at fcc
i am not able to make my own code for the javascript part
Pethaf
@Pethaf
Jul 01 2017 12:29
@PulkitValecha You always have the transform properties for css.
Ahmed Ramy
@Shadilix
Jul 01 2017 12:42

function titleCase(str) {
  var split = str.split(' ');
  var lowerCasing;
  var upperCasing;
  for (var i = 0 ; i < split.length ; i++)
    {
      lowerCasing = split[i].toLowerCase;
      upperCasing = split[i].charAt(0).toUpperCase;
    }
  var titleCased = split.join(' ');

  return titleCased;
}

titleCase("i'm a little tea pot");
okay for some reason , upperCasing doesnt work ... can someone help me with that ?
Pieter Stokkink
@forkerino
Jul 01 2017 12:43
@Shadilix you need to call the methods for upper lower with ()
Ahmed Ramy
@Shadilix
Jul 01 2017 12:43
oh i forgot that
Pethaf
@Pethaf
Jul 01 2017 12:44
@PulkitValecha Built a small demo https://codepen.io/pethaf/pen/BZrLGp?editors=1111
Ahmed Ramy
@Shadilix
Jul 01 2017 12:44
still not working @forkerino
koder3
@koder3
Jul 01 2017 12:45
in record collection advanced algorithm challenge why amnt i able to pass any of the tests even though ive done what they asked correctly
Ogundele Olumide
@Lumexralph
Jul 01 2017 12:46
@koder3 probably you have a global variable?
@forkerino Bro!
koder3
@koder3
Jul 01 2017 12:46
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
return collection[id][prop] = value


}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
test is: After updateRecords(5439, "artist", "ABBA"), artist should be "ABBA" artist is equal to ABBA and it is in collection[5439] so why dont i pass that single test which i just mentioned @Lumexralph
jasonrest
@jasonrest
Jul 01 2017 12:47
Is this the best way to go about making a toggle button for celsius to faren. I tried to use toggle class wasn't working so well.
    //button to change celsius to farenheit
    var celsius = (farenheit - 32) / 9 * 5;
    $("#changetemp").on('click',function(){
        if ('#temp'.html == farenheit){
            '#temp'.html = celsius;
        }
        if ('#temp'.html == celsius){
            '#temp'.html = farenheit;
        }
    });
Stephen James
@sjames1958gm
Jul 01 2017 12:47
@koder3 The instructions say to return the collection object.
Ahmed Ramy
@Shadilix
Jul 01 2017 12:48

function titleCase(str) {
  var split = str.split(' ');
  var lowerCasing;
  var upperCasing;
  for (var i = 0 ; i < split.length ; i++)
    {
      lowerCasing = split[i].toLowerCase;
      upperCasing = split[i].charAt(0).toUpperCase();
    }
  var titleCased = split.join(' ');

  return titleCased;
}

titleCase("I'm a little tea pot");
both lowerCasing and upperCasing Doesnt work , can someone help me with that ???
Stephen James
@sjames1958gm
Jul 01 2017 12:49
@Shadilix You still don't have () on toLowerCase, but you don't do anything with the values that you create
Pieter Stokkink
@forkerino
Jul 01 2017 12:49
@Lumexralph :wave:
ChoiYoungdo
@ChoiYoungdo
Jul 01 2017 12:49

Can anyone help me with this?
Let's say I have this line of codes below:

$('.copy-order').click(function() {

var orders = $(this).siblings().children("h4, h3").text();

console.log(orders);

});

It would print out something like this:
Item 12pc(s). Item 24pc(s)

Which is nice as it prints out the selected content I targeted. However, each element it prints doesn't have whitespace on it. What I want is that it prints outs a line something like this:
Item 1 2pc(s).
Item 2 4pc(s).

How can I achieve that?

Stephen James
@sjames1958gm
Jul 01 2017 12:50
@Shadilix You need to rebuild the string in split[i]
koder3
@koder3
Jul 01 2017 12:50
@sjames1958gm i did return the object. i tried it on https://repl.it/JJ07/1 and i got artist as ABBA. are you saying im supposed to return the WHOLE object along with the updated property ?
Stephen James
@sjames1958gm
Jul 01 2017 12:50
@koder3 Yes the WHOLE object.
Ahmed Ramy
@Shadilix
Jul 01 2017 12:50
@sjames1958gm u mean , join them ?
Ogundele Olumide
@Lumexralph
Jul 01 2017 12:51
@forkerino how're you?
koder3
@koder3
Jul 01 2017 12:51
image.png
Stephen James
@sjames1958gm
Jul 01 2017 12:51
@Shadilix Concatenate the uppercase first letter with the rest of the string
koder3
@koder3
Jul 01 2017 12:51
i did do that though @sjames1958gm
thats what shows
isnt that the whole object
Pieter Stokkink
@forkerino
Jul 01 2017 12:51
@Lumexralph first week at the job was quite tiring, but I feel good. You?
Stephen James
@sjames1958gm
Jul 01 2017 12:52
@koder3 Your function must always return the entire collection object.
return collection;
koder3
@koder3
Jul 01 2017 12:52
oh got it. thanks @sjames1958gm
CamperBot
@camperbot
Jul 01 2017 12:52
koder3 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7969 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
koder3
@koder3
Jul 01 2017 12:53
so close to 8k
Ogundele Olumide
@Lumexralph
Jul 01 2017 12:53
@forkerino enjoying some time with git and it's weekend
Stephen James
@sjames1958gm
Jul 01 2017 12:53
@koder3 yeah :) been slacking a bit lately.
Ahmed Ramy
@Shadilix
Jul 01 2017 12:54
@sjames1958gm am not following u on Concatenate them ... (i dont understand the word itself + Concatenate is like join , only u do that for an array ...)
Stephen James
@sjames1958gm
Jul 01 2017 12:54
@Shadilix concatenate is also for strings "this " + "that"
@Shadilix I didn't want to say join because join is a specific function.
Ahmed Ramy
@Shadilix
Jul 01 2017 12:55
@sjames1958gm but still , what will that help with ? i mean what would concat help with
Stephen James
@sjames1958gm
Jul 01 2017 12:56

@Shadilix

      lowerCasing = split[i].toLowerCase();
      upperCasing = split[i].charAt(0).toUpperCase();

Because strings are not changeable (immutable) these two lines don't modify split[i]
They return new values

Ahmed Ramy
@Shadilix
Jul 01 2017 12:58
@sjames1958gm hmm so how do i change there first char?
to be Capital ... ?
is there's a way of doing that ?
koder3
@koder3
Jul 01 2017 12:58
After updateRecords(5439, "tracks", "Take a Chance on Me"), tracks should have "Take a Chance on Me" as the last element. why doesnt that test pass? it shows the correct values when i return it...
Stephen James
@sjames1958gm
Jul 01 2017 12:58
@Shadilix You don't, you have to make a new string from the old one. Capital first letter + rest of string
@koder3 Is tracks an array?
koder3
@koder3
Jul 01 2017 13:00
@sjames1958gm my bad, thanks rofl.
CamperBot
@camperbot
Jul 01 2017 13:00
koder3 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: koder3 already gave sjames1958gm points
ChoiYoungdo
@ChoiYoungdo
Jul 01 2017 13:00
Hi guys, can anyone help me with something please?
Stephen James
@sjames1958gm
Jul 01 2017 13:00
@Shadilix split[i] = split[i].charAt(0).toUpperCase() + rest of string
ChoiYoungdo
@ChoiYoungdo
Jul 01 2017 13:03

Let's say I have this line of codes below:

$('.copy-order').click(function() {

var orders = $(this).siblings().children("h4, h3").text();

console.log(orders);

});

It would print out something like this:
Item 12pc(s). Item 24pc(s)

Which is nice as it prints out the selected content I targeted. However, each element it prints doesn't have whitespace on it. What I want is that it prints outs a line something like this:
Item 1 2pc(s).
Item 2 4pc(s).

How can I achieve that? Anyone? Help?

Stephen James
@sjames1958gm
Jul 01 2017 13:03
@ChoiYoungdo
$(this).siblings().children("h4, h3")
This returns a collection of items. if you want some special formatting you will need to loop over this collection
ChoiYoungdo
@ChoiYoungdo
Jul 01 2017 13:04
image.png
@sjames1958gm How does one do that tho? :(
image.png
image.png
ChoiYoungdo
@ChoiYoungdo
Jul 01 2017 13:04
image.png
why is it printing out my screen????
Stephen James
@sjames1958gm
Jul 01 2017 13:05
That is weird
ChoiYoungdo
@ChoiYoungdo
Jul 01 2017 13:05
Creepyy lol
@sjames1958gm anyway, thanks I'll check out that link. :clap:
CamperBot
@camperbot
Jul 01 2017 13:06
choiyoungdo sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7970 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Ahmed Ramy
@Shadilix
Jul 01 2017 13:09
@sjames1958gm

function titleCase(str) {
  var split = str.split(' ');
  var lowerCasing;
  var upperCasing;
  for (var i = 0 ; i < split.length ; i++)
    {
      lowerCasing = split[i].toLowerCase;
      upperCasing = split[i].charAt(0).toUpperCase() + split;
    }
  var titleCased = split.join(' ');

  return titleCased;
}

titleCase("I'm a little tea pot");
like this ?
Greta Piliponytė
@gpiliponyte
Jul 01 2017 13:12
Hey guys. Any idea why this code is not working?

getData();

function getData(){
$.getJSON(link, function(data){
status = data.stream;
console.log(status);
})
}

it's not a problem with the link
Kirill
@Kirill255
Jul 01 2017 13:13
Hi guys! Tell me please, what does this error mean? This code is a copy-paste from the challenge Convert JSON Data to HTML, and it doesn't work
$(document).ready(function() {

    $("#refreshQuote").on("click", function() {  

        $.getJSON("https://demo.wp-api.org/wp-json/", function(json) {

            var html = "";

            // Only change code below this line.

            json.forEach(function(val) {

                var keys = Object.keys(val);

                html += "<div class = 'cat'>";

                keys.forEach(function(key) {

                    html += "<strong>" + key + "</strong>: " + val[key] + "<br>";

                });

                html += "</div><br>";

            });

            // Only change code above this line.
       
            $("#outputQuote").html(html);
     
        });

    });

});
Pieter Stokkink
@forkerino
Jul 01 2017 13:14
@Kirill255 you probably don't get an array back from the getJSON call.
.forEach only works on arrays
Ronald T. Casili
@nvlled
Jul 01 2017 13:17
@Kirill255 What @forkerino said, the URL https://demo.wp-api.org/wp-json/ returns a rather large JSON object. Wasn't the original URL /json/cats.json ?
Kirill
@Kirill255
Jul 01 2017 13:19
@forkerino How can i get it ? This is the problem of this server's response "https://demo.wp-api.org/wp-json/" ?
Ahmed Ramy
@Shadilix
Jul 01 2017 13:19

function titleCase(str) {
  var split = str.split(' ');
  var lowerCasing;
  var upperCasing;
  var titleCased;
  for (var i = 0 ; i < split.length ; i++)
    {
      lowerCasing = split[i].toLowerCase;
      upperCasing = split[i].charAt(0).toUpperCase(); 

    }

  return titleCased;
}

titleCase("I'm a little tea pot");
can someone help me with this code?

function titleCase(str) {
  var split = str.split(' ');
  var lowerCasing;
  var upperCasing;
  var titleCased;
  for (var i = 0 ; i < split.length ; i++)
    {
      lowerCasing = split[i].toLowerCase;
      upperCasing = split[i].charAt(0).toUpperCase(); 
      titleCased = upperCasing + split.join(' ');
    }

  return titleCased;
}

titleCase("I'm a little tea pot");
updated
Pieter Stokkink
@forkerino
Jul 01 2017 13:20
@Kirill255 you have to make sure that the JSON you get back is handled correctly. Instead of the json.forEach, just check what it gives you and use it in the correct way. @nvlled said it is an object, so don't treat it as an array.
Kirill
@Kirill255
Jul 01 2017 13:20
@nvlled I took this code as the basis and changed the url of the server
Pieter Stokkink
@forkerino
Jul 01 2017 13:21
@Kirill255 the response of different servers isn't always the same. Sometimes an array, sometimes an object, sometimes just a string.
@Shadilix instead of using a variable titleCased, just overwrite the value that is in split[i] inside your loop. Then at the end you can join and return.
Ronald T. Casili
@nvlled
Jul 01 2017 13:22
@gpiliponyte Which part is not working? What is the output of console.log(status)?
Kirill
@Kirill255
Jul 01 2017 13:23
Ok thanks @forkerino and @nvlled
CamperBot
@camperbot
Jul 01 2017 13:23
kirill255 sends brownie points to @forkerino and @nvlled :sparkles: :thumbsup: :sparkles:
:cookie: 239 | @nvlled |http://www.freecodecamp.com/nvlled
:star2: 2803 | @forkerino |http://www.freecodecamp.com/forkerino
Greta Piliponytė
@gpiliponyte
Jul 01 2017 13:23
@nvlled there is no output... that is the point :D
Ronald T. Casili
@nvlled
Jul 01 2017 13:23
@gpiliponyte What about console.log(data)?
Pieter Stokkink
@forkerino
Jul 01 2017 13:23
@gpiliponyte maybe call the function after you create it?
Moisés Man
@moigithub
Jul 01 2017 13:24
@Shadilix to call functions.. u need to add () after its name
like.. .toUpperCase()
.toLowerCase()
Nitin Sahu
@globefire
Jul 01 2017 13:24
somebody help me i m not getting the typewriter effect
Pieter Stokkink
@forkerino
Jul 01 2017 13:24
@Shadilix yes, why do you still have .toLowerCase without ()?
Ahmed Ramy
@Shadilix
Jul 01 2017 13:25
i forget to add that really :D
like in this
Ahmed Ramy
@Shadilix
Jul 01 2017 13:25
@forkerino ummm should i use replace here ?
Pieter Stokkink
@forkerino
Jul 01 2017 13:25
@Shadilix no
just overwrite
i.e. assign to split[i]
Ahmed Ramy
@Shadilix
Jul 01 2017 13:26
like : titleCased = split[i] ?
Pieter Stokkink
@forkerino
Jul 01 2017 13:26
that assigns to titleCased
Ahmed Ramy
@Shadilix
Jul 01 2017 13:27
hmmm , still wont work properly
Greta Piliponytė
@gpiliponyte
Jul 01 2017 13:28
@forkerino still nothing tho good point
Pieter Stokkink
@forkerino
Jul 01 2017 13:28
@gpiliponyte open your browser's dev console and check for errors.
Greta Piliponytė
@gpiliponyte
Jul 01 2017 13:29
i'm not getting any ...
Pieter Stokkink
@forkerino
Jul 01 2017 13:31
@gpiliponyte can you check the network tab in the dev console, to see if the network request goes out?
Moisés Man
@moigithub
Jul 01 2017 13:33
@gpiliponyte where link coming from ?
its a global variable ?? what value it have when u call getData()
function getData(){
   console.log(link);
    $.getJSON(link...
  ....
}
Dovydas Stirpeika
@Giveback007
Jul 01 2017 13:33
@forkerino :wave:
Ronald T. Casili
@nvlled
Jul 01 2017 13:35
@gpiliponyte Try this, you should see error on the console.
$.getJSON(link, function(data) {
  console.log("X", data);
}).fail(function(err) {
  console.log("fail", err.statusText);
});
Stephen James
@sjames1958gm
Jul 01 2017 13:36
@Shadilix split[i] = UpperCase + rest of string. (lookup slice for getting rest of string)
koder3
@koder3
Jul 01 2017 13:58
function updateRecords(id, prop, value) {

if (prop !== "tracks"){
if (collection[id][prop] === undefined) {
collection[id][prop] = value;
return collection;
} 
}

else if (prop === "tracks" && value !== "") {
if (collection[id]["tracks"] === undefined)   {
collection[id][prop] = [value]
return collection
} else {
collection[id][prop].push(value)
return collection
}
  }

if (value === ""){
delete collection[id][prop]
return collection 
}

}
// Alter values below to test your code
updateRecords(5439, "tracks", "Take a Chance on Me")
@sjames1958gm i solved the algorithm finally, thanks to your help. any way i can optimize it ?
CamperBot
@camperbot
Jul 01 2017 13:58
koder3 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7971 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
shivam gupta
@shivamg11000
Jul 01 2017 13:58

yo web devs, whats the difference between


function Ball(a,b){
  this.a = a;
  this.b = b;
}
class Ball{
  constructor(a,b){
    this.a = a;
    this.b = b;
  }
}

in both

Stephen James
@sjames1958gm
Jul 01 2017 13:59

@koder3 Start with the check on value !== "" then nest the ifs

if (value !== "") {
    if (prop === "tracks") {
    }
    else {
    }
} else {
}

Then you don't have to keep checking value and prop each time

Diego Mayer
@Chrono79
Jul 01 2017 14:00
@koder3 see how many times you've written return collection
maybe you should do it only once (reordering your logic as @sjames1958gm suggested)
Stephen James
@sjames1958gm
Jul 01 2017 14:02
@shivamg11000 Not much difference, there may be some internal structural differences.
class is syntactic sugar in js there is no "class" in the basic js
koder3
@koder3
Jul 01 2017 14:03
@Chrono79 @sjames1958gm hmm thats much better. yeah i should probably just return it at the end after the if elses. thanks a lot.
CamperBot
@camperbot
Jul 01 2017 14:03
koder3 sends brownie points to @chrono79 and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: koder3 already gave sjames1958gm points
:star2: 4452 | @chrono79 |http://www.freecodecamp.com/chrono79
ADIL KARMOUZI
@mradil16
Jul 01 2017 14:04
Hi guys . Can I stop a while loop , then continue looping until the condition is met ?
Stephen James
@sjames1958gm
Jul 01 2017 14:05
@mradil16 You mean like jump to the end of the current iteration?
Ahmed Ramy
@Shadilix
Jul 01 2017 14:05

function titleCase(str) {
  var lowerCasing = str.toLowerCase();
  var split = lowerCasing.split(' ');
  var upperCasing;
  for(var i = 0; i < split.length ; i++)
    {
      upperCasing = split[i].replace(/split[i].charAt(0)/i , split[i].toUpperCase());
    }
  return upperCasing;
}

titleCase("I'm a little tea pot");
@sjames1958gm so i tried another approach here but the result remains the same
Dovydas Stirpeika
@Giveback007
Jul 01 2017 14:06
@mradil16 do you mean manually?
Stephen James
@sjames1958gm
Jul 01 2017 14:06
@Shadilix Why not put the changed value back into split[i] and then you can join split at the end ?
Ahmed Ramy
@Shadilix
Jul 01 2017 14:07
by the change value u mean changing upperCasing to split ?
Saif Ur Rahman
@saifsmailbox98
Jul 01 2017 14:08
@Shadilix :wave:
Ahmed Ramy
@Shadilix
Jul 01 2017 14:08
@saifsmailbox98 Saif ! how's it going :D
Stephen James
@sjames1958gm
Jul 01 2017 14:08
@Shadilix /split[i].charAt(0)/i this is not at all going to work.
split[i] = split[i].replace(split[i].charAt(0), split[i].charAt(0).toUpperCase());
Saif Ur Rahman
@saifsmailbox98
Jul 01 2017 14:08
@Shadilix good, doing the backends.
what about you
?
Ahmed Ramy
@Shadilix
Jul 01 2017 14:09
still doing the algorithim challenges
@sjames1958gm okay will try that
Saif Ur Rahman
@saifsmailbox98
Jul 01 2017 14:09
:+1:
Stephen James
@sjames1958gm
Jul 01 2017 14:09
@Shadilix You have an array of words in lower case. Change each word in the array to
a word with first letter in upper case.
Ahmed Ramy
@Shadilix
Jul 01 2017 14:10
@sjames1958gm then join it together to form a string
Stephen James
@sjames1958gm
Jul 01 2017 14:11
@Shadilix After the loop - you had that at one time
Ahmed Ramy
@Shadilix
Jul 01 2017 14:14

function titleCase(str) {
  var lowerCasing = str.toLowerCase();
  var split = lowerCasing.split(' ');
  var upperCasing;
  for(var i = 0; i < split.length ; i++)
    {
      split = split[i].replace(split[i].charAt(0), split[i].charAt(0).toUpperCase());
    }
  return split;
}

titleCase("I'm a little tea pot");
@sjames1958gm
Stephen James
@sjames1958gm
Jul 01 2017 14:15
@Shadilix How is that replacing the word in split? you are wiping out the array on the first pass in the loop?
koder3
@koder3
Jul 01 2017 14:15
return arguments[1].filter((v) => if (arguments[0].indexOf(v) !== -1) {return arguments[1] !== v}) whats wrong in this. is it not allowed to put ifs in arrow functions ?
Diego Mayer
@Chrono79
Jul 01 2017 14:16
@koder3 try with ternary operator
Stephen James
@sjames1958gm
Jul 01 2017 14:16
@koder3 You have to use {} if there is something other than an expression in the function
koder3
@koder3
Jul 01 2017 14:16
@sjames1958gm @Chrono79 so i can use ternarys but not ifs?
Diego Mayer
@Chrono79
Jul 01 2017 14:16
but you can't use arguments in arrow functions if I remember well
Ahmed Ramy
@Shadilix
Jul 01 2017 14:18
@sjames1958gm thats what u told me to do ...
or am i wrong ?
Stephen James
@sjames1958gm
Jul 01 2017 14:18
arrow functions don't define arguments, but you can use outer scoped arguments
koder3
@koder3
Jul 01 2017 14:18
@sjames1958gm @Chrono79 alright. thanks
CamperBot
@camperbot
Jul 01 2017 14:18
koder3 sends brownie points to @sjames1958gm and @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: koder3 already gave chrono79 points
:warning: koder3 already gave sjames1958gm points
Stephen James
@sjames1958gm
Jul 01 2017 14:18
@Shadilix split[i] = split[i].replace(split[i].charAt(0), split[i].charAt(0).toUpperCase());
I said change split[i] not all of split
Ahmed Ramy
@Shadilix
Jul 01 2017 14:19
ok
tommy
@tommygebru
Jul 01 2017 14:22

Quick Question: whats the hardest thing to learn about es6 ?

That people take the most time on to understand conceptually - maybe?

Ahmed Ramy
@Shadilix
Jul 01 2017 14:23
@sjames1958gm Thanks ! i passed it
CamperBot
@camperbot
Jul 01 2017 14:23
shadilix sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7972 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jul 01 2017 14:23
@Shadilix Cool. Now study that code until you understand it
JHnnis
@JHnnis
Jul 01 2017 14:24
The "profile lookup" challenge in Java Script is very very challenging holy moly..
koder3
@koder3
Jul 01 2017 14:25
@tommygebru destructuring for me. it isnt hard although it took me time.
Stephen James
@sjames1958gm
Jul 01 2017 14:25
@JHnnis Take it step by step. Get the return of the valid property first, then the missing property, then no such contact last.
JHnnis
@JHnnis
Jul 01 2017 14:26
@sjames1958gm so I need a for loop + nested if statement right?
luccifer00
@luccifer00
Jul 01 2017 14:26

i am still trunk on quote random machine...

$(document).ready(function() {
    $("#getMessage").on("click", function(){


      $.getJSON("https://quotes.rest/qod.json", function(json) {

        var html="";

        json.forEach(function(val) {
var keys = Object.keys(val);
html += "<div class = 'cat'>";
keys.forEach(function(key) {
html += "<strong>" + key + "</strong>: " + val[key] + "<br>";
});
html += "</div><br>";
});

$(".message").html(html);
});


    });

  });

i have that code on JS code pen, libraries are set. I dont have any response when i push the button...
Any idea? --- here is my code pen link

Pieter Stokkink
@forkerino
Jul 01 2017 14:26
@tommygebru Symbol.iterator? Generator Functions? Proxies?
mitron6
@mitron6
Jul 01 2017 14:27
@JHnnis A loop + nested if statements is one way to solve this
Stephen James
@sjames1958gm
Jul 01 2017 14:27
@JHnnis That is the most common way to solve
@luccifer00 Did you try console.log inside the getJSON callback?
@tommygebru Of the more commonly use features, I would say promises.
@luccifer00 I see an error in the console.
tommy
@tommygebru
Jul 01 2017 14:29
ok I will look into these thanks @forkerino @sjames1958gm :smile_cat:
CamperBot
@camperbot
Jul 01 2017 14:29
tommygebru sends brownie points to @forkerino and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2804 | @forkerino |http://www.freecodecamp.com/forkerino
:star2: 7973 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
JHnnis
@JHnnis
Jul 01 2017 14:29
@sjames1958gm @mitron6 but i'm struggling with the order :worried: is it right to take one loop with 2 nested if statements or 2 separated loops?
Stephen James
@sjames1958gm
Jul 01 2017 14:30
@luccifer00 Are you using chrome?
mitron6
@mitron6
Jul 01 2017 14:30
@JHnnis Try it first with one loop. It is easier.
luccifer00
@luccifer00
Jul 01 2017 14:30
@sjames1958gm no i didnt, i never use console.log, im always use return.... freecodecam never teach me to use console.log. No i am using firefox
ADIL KARMOUZI
@mradil16
Jul 01 2017 14:30
@sjames1958gm I think about a little game . There is a box , full of balls ( 150 ball ) and I want to check first how much balls the box contains and display the value in the console , then keep looping until the box is empty . do you have any suggestions ?
Stephen James
@sjames1958gm
Jul 01 2017 14:30
@JHnnis Just the one loop.
If you had a stack of business cards, would you need to go through them twice to find a contact and check for the email property?
luccifer00
@luccifer00
Jul 01 2017 14:31
@sjames1958gm i dont know where to place console.log...
Stephen James
@sjames1958gm
Jul 01 2017 14:32
@luccifer00 right after your var = html("")
So try this, enter the URL into your browser address bar, and see the json returned.
JHnnis
@JHnnis
Jul 01 2017 14:32
@sjames1958gm @mitron6 okay thanks that sounds logical, sometimes you have to think different right? :D
CamperBot
@camperbot
Jul 01 2017 14:32
jhnnis sends brownie points to @sjames1958gm and @mitron6 :sparkles: :thumbsup: :sparkles:
:cookie: 757 | @mitron6 |http://www.freecodecamp.com/mitron6
:star2: 7974 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jul 01 2017 14:33

@luccifer00 You can see from this snippet the json is not an array but an object. But, json.contents.quotes is an array which would support forEach

{
    "success": {
        "total": 1
    },
    "contents": {
        "quotes": [

The first thing to do when the code isn't working is to open the developer tools and look for errors.

mitron6
@mitron6
Jul 01 2017 14:34
@JHnnis The first step is to do something like you learned in https://www.freecodecamp.com/challenges/iterate-through-an-array-with-a-for-loop.
Stephen James
@sjames1958gm
Jul 01 2017 14:34
@JHnnis :+1: Sometimes it helps to relate the code to real world activities and how you would go about doing them.
@mradil16 What data structure is the box? How do you check for how many balls are in the box?
mitron6
@mitron6
Jul 01 2017 14:35
@JHnnis Inside the for loop, you do something like you learned in https://www.freecodecamp.com/challenges/testing-objects-for-properties.
@JHnnis For most folks, the most challenging part is how to tell if the contact is not found.
JHnnis
@JHnnis
Jul 01 2017 14:37
@mitron6 okay i will try that :)
luccifer00
@luccifer00
Jul 01 2017 14:38
@sjames1958gm interesting... i see .. thanks for all the info, where is the developer tools???? is the console.log??
CamperBot
@camperbot
Jul 01 2017 14:38
luccifer00 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7975 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Hemakshi Sachdev
@hemakshis
Jul 01 2017 14:39
hey everyone.. i am working with my wikipedia viewer.. i wanted my search icon to move to left side when my mouse would be over it.. i used .animate() and made marginLeft: +='[val]px'; it works fine but in addition to moving left it goes down also.. i really don't understand why is this happening
Stephen James
@sjames1958gm
Jul 01 2017 14:39
@luccifer00 I don't use firefox, so I am not sure how you open them on firefox. They are built into the browser
Hemakshi Sachdev
@hemakshis
Jul 01 2017 14:39
can anybody tell why is this happening???
luccifer00
@luccifer00
Jul 01 2017 14:40
okk!! @sjames1958gm
ADIL KARMOUZI
@mradil16
Jul 01 2017 14:44
@sjames1958gm
var balls = 150;

while (balls > 0){
   console.log("Now, you have " + balls + " in the box");
   console.log("Pass one ball around");
   balls--;

   if(!(balls > 0)){
      console.log("The box is empty");
}
}
Sandip Shrestha
@saninmersion
Jul 01 2017 14:44
@hemakshis that's animate behaving
Hemakshi Sachdev
@hemakshis
Jul 01 2017 14:46
@saninmersion but why is it moving down?? It works correctly in codepen. but not when i'm using brackets
Ronald T. Casili
@nvlled
Jul 01 2017 14:46
Sweet Coding :)
@SweetCodingInc
Jul 01 2017 14:48
@hemakshis Do you have codepen?
Hemakshi Sachdev
@hemakshis
Jul 01 2017 14:49
@SweetCodingInc yes.. but i want to work in brackets nd not codepen
Sweet Coding :)
@SweetCodingInc
Jul 01 2017 14:50
@hemakshis can you share codepen link? May be problem can be found there as well
Hemakshi Sachdev
@hemakshis
Jul 01 2017 14:50
ok..
@SweetCodingInc in codepen i have not put the icon nd input within a div but i'm doing so in the editor.. is the problem bcoz of that??
shivam gupta
@shivamg11000
Jul 01 2017 14:53
not possible to work differently in different code editors if the code is same
Sweet Coding :)
@SweetCodingInc
Jul 01 2017 14:53
Can you update your codepen with the same changes you have made to your code in brackets? @hemakshis
Hemakshi Sachdev
@hemakshis
Jul 01 2017 14:56
okay.. just wait for a minute @SweetCodingInc
Kshitijaa Jaglan
@KshitijaaJaglan
Jul 01 2017 14:57
In the challenge Make Unique Objects By Passing Parameters to Our Constructor, why doesn't this code work??
Stephen James
@sjames1958gm
Jul 01 2017 14:57
@mradil16 How do you want modify this?
Kshitijaa Jaglan
@KshitijaaJaglan
Jul 01 2017 14:57

``` var Car = function() {
//Change this constructor
this.wheels = 4;
this.seats = 5;
this.engines = 1;
};

//Try it out here
var myCar = function(wheels,seats,engines){
this.wheels = wheels;
this.seats = seats;
this.engines=engines;
};
var myCar = new Car(3,1,2); ```

Sweet Coding :)
@SweetCodingInc
Jul 01 2017 14:58
@KshitijaaJaglan backticks must be on their own lines
Stephen James
@sjames1958gm
Jul 01 2017 14:58
@KshitijaaJaglan Change this constructor - the one above, not create a new one.
Hemakshi Sachdev
@hemakshis
Jul 01 2017 14:59
@SweetCodingInc here you go.. same problem in this also.. maybe i have made some mistake this time
https://codepen.io/hemakshis/pen/bRvgVz
Stephen James
@sjames1958gm
Jul 01 2017 14:59
@KshitijaaJaglan Use shift-enter to get new line without posting. You can edit your posts, up arrow to edit last one
Kshitijaa Jaglan
@KshitijaaJaglan
Jul 01 2017 15:04
@sjames1958gm so what am I supposed to do?
Stephen James
@sjames1958gm
Jul 01 2017 15:05
@KshitijaaJaglan edit the constructor at the top Car, adding parameters and using them
shivam gupta
@shivamg11000
Jul 01 2017 15:06
@hemakshis

#search-btn{
  position: absolute;
  left: 0;
}
Stephen James
@sjames1958gm
Jul 01 2017 15:06
@hemakshis your search box isn't wide enough when you add the margin, so it goes to the next "line"
shivam gupta
@shivamg11000
Jul 01 2017 15:07
add this to your css at the bottom
@hemakshis
Christopher McCormack
@cmccormack
Jul 01 2017 15:08
@hemakshis one thing - if you want it to move left you should do -= not +=
shivam gupta
@shivamg11000
Jul 01 2017 15:09
@hemakshis and your margin-left animation is not working
Stephen James
@sjames1958gm
Jul 01 2017 15:09
@hemakshis So when you fade in the input then the button margin is relative to the input not the right edge of the search box
shivam gupta
@shivamg11000
Jul 01 2017 15:09
it goes to right because the seach bar comes up
@hemakshis
Hemakshi Sachdev
@hemakshis
Jul 01 2017 15:09
@cmccormack @shivamg11000 sorry i meant right
luccifer00
@luccifer00
Jul 01 2017 15:10

@sjames1958gm you were rigth! i have a TypeError on developer tools... i read this link and i change the var html =""; to var html=[]; and no fix the error, anyway I also add the url json.contents.quotes , and i have an error of permisións.... by the way , i tried to do it, on browser also, and i get an error, i only can acces to that json Api, throw the link they providme on his wesite What can i do next??

I am happy becouse i am making questions knowing his meaning, and that is a bit step to learning! Thanks /@all freecodecamp here in the chat to help each others to solve his problems. Most of you are essential for us!!

CamperBot
@camperbot
Jul 01 2017 15:10
luccifer00 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: luccifer00 already gave sjames1958gm points
Christopher McCormack
@cmccormack
Jul 01 2017 15:12
@hemakshis you're adding margin to your button which is pushing it to the next line - maybe make the button position relative and use left instead of marginLeft
luccifer00
@luccifer00
Jul 01 2017 15:12
sorry the website is that, no the http://quotes.rest/qod.js i said before
Stephen James
@sjames1958gm
Jul 01 2017 15:12

@luccifer00 You are trying to do forEach on the json, so you need to get to the part of the json that is an array.

        console.log(json);

        json.contents.quotes.forEach(function(val) {

The json object show log to the devtools console

luccifer00
@luccifer00
Jul 01 2017 15:13
so clear! @sjames1958gm perfect! i am getting to understand
Stephen James
@sjames1958gm
Jul 01 2017 15:14
@luccifer00 :+1:
ADIL KARMOUZI
@mradil16
Jul 01 2017 15:15
@sjames1958gm I want to check the "balls" variable's value , if it's equal to 150 , stop the " loop " and display " Now you have 150 balls in the box". When the variable is decremented by 1 , display " You still have {var} in the box " and keep looping after that until the box is empty.
Kshitijaa Jaglan
@KshitijaaJaglan
Jul 01 2017 15:15
@sjames1958gm I tried this, but it didn't work.
var Car = function(wheels, seats, engines) {
  //Change this constructor
  this.wheels = 4;
  this.seats = 5;
  this.engines = 1;
};
//Try it out here
var myCar = new Car(3,1,2);
Stephen James
@sjames1958gm
Jul 01 2017 15:16
@KshitijaaJaglan because you didn't use the new parameters you added
Hemakshi Sachdev
@hemakshis
Jul 01 2017 15:16
@sjames1958gm is there anyway to make it move relative to the right edge of my search-box??
shivam gupta
@shivamg11000
Jul 01 2017 15:16
@KshitijaaJaglan use this instead
function Car(wheels, seats, engines) {
  //Change this constructor
  this.wheels = wheels;
  this.seats = seats;
  this.engines = engines;
};
//Try it out here
var myCar = new Car(3,1,2);
Stephen James
@sjames1958gm
Jul 01 2017 15:17
@shivamg11000 better not to give answers.
Christopher McCormack
@cmccormack
Jul 01 2017 15:17
@hemakshis if you make the #search-btn position: absolute; should work, along with using left instead of marginLeft
shivam gupta
@shivamg11000
Jul 01 2017 15:17
@sjames1958gm oops
Stephen James
@sjames1958gm
Jul 01 2017 15:18
@shivamg11000 If they are having trouble with the website projects, yes specific help is ok. But for the challenges, better to give hints that answers. IMO :)
Keon Samuel
@keonsam
Jul 01 2017 15:18
@sjames1958gm what is the most awesome ground break program you ever made?
Stephen James
@sjames1958gm
Jul 01 2017 15:18
@mradil16 Well you could put that first if/display before the while loop.
Kshitijaa Jaglan
@KshitijaaJaglan
Jul 01 2017 15:19
Thanks @sjames1958gm and @shivamg11000
I used this code
var Car = function Car(wheels, seats, engines) {
  //Change this constructor
  this.wheels = wheels;
  this.seats = seats;
  this.engines = engines;
};
//Try it out here
var myCar = new Car(3,1,2);
CamperBot
@camperbot
Jul 01 2017 15:19
kshitijaajaglan sends brownie points to @sjames1958gm and @shivamg11000 :sparkles: :thumbsup: :sparkles:
:cookie: 341 | @shivamg11000 |http://www.freecodecamp.com/shivamg11000
:star2: 7976 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Hemakshi Sachdev
@hemakshis
Jul 01 2017 15:20
@cmccormack yes it worked.. thanks a lot :)
CamperBot
@camperbot
Jul 01 2017 15:20
hemakshis sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 980 | @cmccormack |http://www.freecodecamp.com/cmccormack
Stephen James
@sjames1958gm
Jul 01 2017 15:21
@keonsam Most of my coding is not user facing, so it is hard to say. But I did get a company award for creating a telephony switch simulator for
a customer saving a multi-million dollar deal.
Christopher McCormack
@cmccormack
Jul 01 2017 15:22
@hemakshis np
Hemakshi Sachdev
@hemakshis
Jul 01 2017 15:22
@sjames1958gm @shivamg11000 thanku for your help too :)
CamperBot
@camperbot
Jul 01 2017 15:22
hemakshis sends brownie points to @sjames1958gm and @shivamg11000 :sparkles: :thumbsup: :sparkles:
:cookie: 342 | @shivamg11000 |http://www.freecodecamp.com/shivamg11000
:star2: 7977 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
ADIL KARMOUZI
@mradil16
Jul 01 2017 15:28

@sjames1958gm I got this result :

Now, you have 150 in the box
you still have 150 ball in the box
you still have 149 ball in the box

I want to exclude the number 150 from the loop when the variable is decremented by 1.

Sweet Coding :)
@SweetCodingInc
Jul 01 2017 15:28

@hemakshis : Sorry for delayed response. I was away. I made a few adjustment to your pen. Take a look

https://codepen.io/SweetCodingInc/pen/gRegmB

Stephen James
@sjames1958gm
Jul 01 2017 15:28
@mradil16 Put the log after the -- ?
@hemakshis :+1:
@mradil16 You can put that in the else to your this box is empty output
Ayman Bakri
@aymanbakri
Jul 01 2017 15:31

hey everyone , i'm trying to create a website by javascript , i have this functions

//it receive products and make array that contains the tags from the second function and it should append the tags to the html
  initial: function (products) {
        var htmlProducts = [];
        for (var i = 0; i < products.length; i++) {
            htmlProducts.push(this.createProduct(products[i]));
        }
        var parent = document.getElementById("products");
        parent.append(htmlProducts);
    },
//its make the div tags that contain the product name 
createProduct: function (product) {
        var productWrapper = document.createElement("div")
        productWrapper.className = "productHolder";

        var prodName = document.createElement("div")
        prodName.className = "productName";
        prodName.innerHTML = product.name;

        productWrapper.append(prodName);
        return productWrapper;
    },

but now its return object HTMLDivElement , how i can get the productWrapper in the html
thats what i had received in the html [object HTMLDivElement],[object HTMLDivElement],[object HTMLDivElement],[object HTMLDivElement],[object HTMLDivElement],[object HTMLDivElement],[object HTMLDivElement],[object HTMLDivElement]

koder3
@koder3
Jul 01 2017 15:40
how should i use reduce in the "symmetric difference" challenge. theres more than 1 array.
jasonrest
@jasonrest
Jul 01 2017 15:41
Im trying to create a toggle button to switch between celsius and farenheit.
Should this solution be working appropriately? ...it's not.
 //button to change celsius to farenheit
    var tempSwap = true;

    $('#changeTemp').click(function(){
        if(tempSwap === false){
            $('#changeTemp').html(farenheit);
            tempSwap = true;
        }
        else {
            $('#changeTemp').html(celsius)
        }
    })
Ahmed Ramy
@Shadilix
Jul 01 2017 15:42

function largestOfFour(arr) {
  // You can do this!
  var largestNum = [];
  for(var i = 0; i < arr.length;i++)
    {
      for(var j = 0; j <arr[i].length ; j++)
        {
          if (largestNum < arr[i][j])
            {
              largestNum = arr[i][j];
            }

        }
    }
  return largestNum;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
okay this code returns the largest number in the whole array , i am supposed to return the largest number of each sub-array
any ideas ?
Moisés Man
@moigithub
Jul 01 2017 15:44
var largestNum = []; is an array
arr[i][j] <... what this contains ?
variables are containers.. they hold/store values