These are chat archives for FreeCodeCamp/Help

5th
Oct 2018
Leena
@leena-d
Oct 05 2018 00:38
can someone explain what i'm doing wrong that's preventing this last test from passing? i read what it says but it doesn't make any sense to me. https://codepen.io/leena-d/pen/kXmzNN?editors=1100#0
it would also be nice to know why my media query doesn't work when the viewport is resized
abraham anak agung
@padunk
Oct 05 2018 01:00
@leena-d i think you should give your navbar margin top of 50px. So it will show up, cause right now, i can't see the navbar
Leena
@leena-d
Oct 05 2018 01:10
oops thanks. totally fixed it @padunk

```function titleCase(str) {

var arr = str.toLowerCase().split(' ');
var nstring = ""
for(var i=0;i<arr.length;i++)
{ var narr = arr[i].split('');
for(var j=0; j<narr.length;j++)
{
nstring += j===0 ? narr[j].toUpperCase() : narr[j];
}
nstring+=" ";

}

console.log(nstring)
return nstring;
}

titleCase("I'm a little tea pot");```

I think My solution is correct
and it show correct result in console.log
Claudio Restifo
@Marmiz
Oct 05 2018 05:34
formatted your code for readability @karanshrm44
function titleCase(str) {

var arr = str.toLowerCase().split(' ');
var nstring = ""
for(var i=0;i<arr.length;i++)
{ var narr = arr[i].split('');
for(var j=0; j<narr.length;j++)
{
nstring += j===0 ? narr[j].toUpperCase() : narr[j];
}
nstring+=" ";

}

console.log(nstring)
return nstring;
}

titleCase("I'm a little tea pot");
@karanshrm44 btw your solution is incorrect because you have an extra space at the end of the phrase
Pankaj kumar
@pankajchanda94
Oct 05 2018 08:12
hello there, i am preparing for OCAJP certification and need a small help regarding following question
Which variables are in scope for the entire program: Class, Local or Instance?
Niraj Nandish
@Nirajn2311
Oct 05 2018 09:36
Global scope variables are in scope of entire program.
May Kittens Devour Your Soul
@diomed
Oct 05 2018 09:38
this above is java, tho
May Kittens Devour Your Soul
@diomed
Oct 05 2018 10:01
(/◔ ◡ ◔)/
Kranti Nebhwani
@darkphotonKN
Oct 05 2018 10:05
anyone got a good idea for a landing page short message saying "We create your web site / apps" in a slicker maybe even shorter way?
Fabien SHAN
@X140hu4
Oct 05 2018 10:11
WCYWS/A
Ready to take your business on the line?
xx% of people in Taiwan use mobile phones/internet to lookup businesses. Where are you?
Kranti Nebhwani
@darkphotonKN
Oct 05 2018 10:22
thanks
how do you know im in taiwan lol
@X140hu4
psyperl
@psyperl
Oct 05 2018 10:39
Screen Shot 2018-10-05 at 17.37.49.png
Kranti Nebhwani
@darkphotonKN
Oct 05 2018 10:39
ah ok
psyperl
@psyperl
Oct 05 2018 10:40
:smile:
abraham anak agung
@padunk
Oct 05 2018 10:58
Hi, anybody use rollup?
May Kittens Devour Your Soul
@diomed
Oct 05 2018 11:02
@psyperl is NSA. he knows everything about you
psyperl
@psyperl
Oct 05 2018 11:54
lol
wew i just had a crazy thought
/// something like...
const promise1 = x => new Promise(...)
const promise2 = x => new Promise(...)
[promise1, promise2].reduce( (b,v) => b.then( v ) )
May Kittens Devour Your Soul
@diomed
Oct 05 2018 12:11
is it ok if I axolotl questions?
psyperl
@psyperl
Oct 05 2018 12:12
axolotf
Aditya
@ezioda004
Oct 05 2018 12:42
@psyperl That works, not super intuitive though at first glance
ehutchllew
@ehutchllew
Oct 05 2018 12:47
@psyperl @ezioda004 would a promise.all not work here?
psyperl
@psyperl
Oct 05 2018 12:50
promise all for parallel yes .. but i think the code above is for a promise sequence where one waits for the result of the previous promise
Aditya
@ezioda004
Oct 05 2018 12:51
Yeah, its essentially, sync promises rather than parallel promises
class DisplayMessages extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      input: '',
      messages: []
    }
this.handleChange = this.handleChange.bind(this)
    this.submitMessage = this.submitMessage.bind(this)
  }


  // add handleChange() and submitMessage() methods here
handleChange(e) {
    this.setState({
      input: e.currentTarget.value
    });
  }

  submitMessage() {
      let newMessages = [...this.state.messages, this.state.input];
   this.setState({
     messages: newMessages,
     input: ''
   })

  }
  render() {
    return (
      <div>
        <h2>Type in a new Message:</h2>
        { /* render an input, button, and ul here */ }
                  <input value={this.state.input} onChange={this.handleChange} />
        <button onClick={this.submitMessage}>Add message</button>
        <ul>
           {this.state.messages.map(msg => <li>{msg}</li>)}
        </ul>

        { /* change code above this line */ }
      </div>
    );
  }
};
what's wrong with this/
Anand Potukuchi
@anandpotukchi
Oct 05 2018 13:18
any idea////
??????
@ezioda004
Anand Potukuchi
@anandpotukchi
Oct 05 2018 13:27
anybody??????
hello???????????
Ruben Dario
@rubendmatos1985
Oct 05 2018 13:28
@anandpotukchi you need to wright a key
Anand Potukuchi
@anandpotukchi
Oct 05 2018 13:29
where?
Ruben Dario
@rubendmatos1985
Oct 05 2018 13:29
this.state.messages.map((msg,index) => <li key={index}>{msg}</li>)
@anandpotukchi did you see it?
Aditya
@ezioda004
Oct 05 2018 13:44
@anandpotukchi Change input: e.currentTarget.value to e.target.value
ehutchllew
@ehutchllew
Oct 05 2018 14:20
@psyperl you can also do async/await:
async getRespones(){
    const promise1 = await new Promise(...);
    const promise2 = await new Promise(...):
    //whatever else you need to do
}
Kyle Holm
@thekholm80
Oct 05 2018 14:21
doesn't react get grumpy if you use indices as keys when you map over arrays for render?
psyperl
@psyperl
Oct 05 2018 14:29
@ehutchllew thanks yeah.. i could do that also, except the part that i haven't really learn async await yet
Aditya
@ezioda004
Oct 05 2018 14:29
@thekholm80 Yeah I think so
@psyperl That example is what async-await is :smile:
Kyle Holm
@thekholm80
Oct 05 2018 14:31
it's really that simple
async is required in the function / method declaration async function foo() { and then await in the assignment to indicate the resolving value will be a promise
Kyle Holm
@thekholm80
Oct 05 2018 14:37
@ezioda004 x
Aditya
@ezioda004
Oct 05 2018 14:42
lol
psyperl
@psyperl
Oct 05 2018 14:53
hehe
thanks for clarifying @thekholm80 @ezioda004
May Kittens Devour Your Soul
@diomed
Oct 05 2018 15:04
lol - I'm back guys
got lost in the forest today
psyperl
@psyperl
Oct 05 2018 15:04
but i think that's more similar to promise all than a chained promises
@diomed wb
did you get signals in the forest?
May Kittens Devour Your Soul
@diomed
Oct 05 2018 15:05
thanks. let me tell you - forest ain't no place for cats
psyperl
@psyperl
Oct 05 2018 15:08
in case if you don't get signals in the forest.. is safer to buy some signals first before going in to the forest.. that way you don't run out of signals when you are there
Kyle Holm
@thekholm80
Oct 05 2018 15:08
I buy my signals in bulk, that way it's cheaper
psyperl
@psyperl
Oct 05 2018 15:09
^
Aditya
@ezioda004
Oct 05 2018 15:09
@psyperl async await similar to promise.all?
psyperl
@psyperl
Oct 05 2018 15:10
@ezioda004 i don't know? are they?
can one feed the result of previous promise as param to the next promise that way? ( using await )
Aditya
@ezioda004
Oct 05 2018 15:11
Promise.all()does the job in parallel. The above async await example waits before starting a new promise
psyperl
@psyperl
Oct 05 2018 15:11
ah
May Kittens Devour Your Soul
@diomed
Oct 05 2018 15:11
I gave my mum my cell phone, and she just left me in the woods
do you think they're trying to get rid of me?
Aditya
@ezioda004
Oct 05 2018 15:12
Ofcourse
const x = await new Promise(//stuff);
const y = await new Promise((res) => //do something with x);
psyperl
@psyperl
Oct 05 2018 15:13
@ezioda004 that's weird.. i thought x is a promise
Aditya
@ezioda004
Oct 05 2018 15:13
@psyperl Yes it is, though you can still use a promise inside a promise
psyperl
@psyperl
Oct 05 2018 15:14
congrats @ezioda004 .. now i am confused lol
Anand Potukuchi
@anandpotukchi
Oct 05 2018 15:14
const ADD = 'ADD';

function addMessage (msg) {
  return {
    type: ADD,
    message: msg
  }
};
const messageReducer = (state = [], action) => {
  switch (action.type) {
    case ADD: return [...state,action.meesage];
    break;
    default:
      return state;
  }
};
const store = Redux.createStore(messageReducer);
Aditya
@ezioda004
Oct 05 2018 15:14
@psyperl Lol why?
May Kittens Devour Your Soul
@diomed
Oct 05 2018 15:14
@ezioda004 how to write a promise when you borrow your neighbor some tool and he promises to give it back, but then he doesn't?
Aditya
@ezioda004
Oct 05 2018 15:15
@diomed You snitch and call 911
May Kittens Devour Your Soul
@diomed
Oct 05 2018 15:16
I expected js version of it and got this :-|
Anand Potukuchi
@anandpotukchi
Oct 05 2018 15:16
@diomed simple. borrow it from him and don't write a promise, saves time.
@ezioda004
why do i freaking suck at react and redux
May Kittens Devour Your Soul
@diomed
Oct 05 2018 15:17
coz you're still getting to know it
psyperl
@psyperl
Oct 05 2018 15:17
const promiseToGiveBackToolsToNeightbour = tool =>  {
  mystash.push(tool)
  return new Promise( (kept, broken) => broken() )
}
May Kittens Devour Your Soul
@diomed
Oct 05 2018 15:17
it's like a friend you're meeting , and it's awkward, then u get used to it
what is this mystash.push thingie?
psyperl
@psyperl
Oct 05 2018 15:19
to put your neighbour's tool in your stash.. not bringing it back
Aditya
@ezioda004
Oct 05 2018 15:20
@anandpotukchi You have a typo [...state,action.meesage], should be message
Anand Potukuchi
@anandpotukchi
Oct 05 2018 15:20
f*k
and that is wy i hate myself
Aditya
@ezioda004
Oct 05 2018 15:21
Also, no point in using break if you have return before it
psyperl
@psyperl
Oct 05 2018 15:22
i use line break after return why not
May Kittens Devour Your Soul
@diomed
Oct 05 2018 15:22
it's better to typo as massage than message
psyperl
@psyperl
Oct 05 2018 15:28
¿ǝƃɐssǝɯ
May Kittens Devour Your Soul
@diomed
Oct 05 2018 15:38
now make me a cd
psyperl
@psyperl
Oct 05 2018 15:41
make: *** No rule to make target 'me'. Stop.
gonna check my coffee... hopefully its done
psyperl
@psyperl
Oct 05 2018 15:55

ok which one is better

const func1 = (paramA, paramB) => 1

or

const func1 =(paramA,paramB)=> 1

?

May Kittens Devour Your Soul
@diomed
Oct 05 2018 15:59
frst
psyperl
@psyperl
Oct 05 2018 15:59
ok thanks
Anand Potukuchi
@anandpotukchi
Oct 05 2018 16:32
I have a question
my memory is pretty weak
how am i supposed to remeber all the concepts
in these challenges
for ex I just went back, and had a look at my mongo challenges solutions, don't remember anything
Anand Potukuchi
@anandpotukchi
Oct 05 2018 16:37
?
psyperl
@psyperl
Oct 05 2018 16:42
you noticed that in the past 2 weeks i mainly talk about Promises.. that's my effort to remember what it is.. must be another more effective way to remember things, but what i did is to put it in practice and do it over and over again
Aditya
@ezioda004
Oct 05 2018 16:48
Repetition helps to retain
psyperl
@psyperl
Oct 05 2018 17:09
diagrams help too
Bjorn van de Peut
@bjorno43
Oct 05 2018 18:32
Well I've finally figured out why bobsbotty is no longer responding after x amount of hours. The issue is, it shouldn't be happening.. :cry:
The issue is "MySQL has gone away". Which is an error that occurs if you're using a persistent connection for too long. Trouble is, I'm not using a persistent connection..
Bjorn van de Peut
@bjorno43
Oct 05 2018 19:20
Well I've just thrown in a bunch of exception handlers that try to reconnect in case the connection is lost. Hopefully the problem is solved now
psyperl
@psyperl
Oct 05 2018 19:44
wew @bjorno43 congrats.. hopefully works better
i found new way to use Promises!
using another
const toTest = (k,b,x) => k(x+1)
const promiseToTest = x =>
  new Promise((k,b) => toTest(k,b,x))

const toTest2 = (k,b,x) => k(x+2)
const promiseToTest2 = x =>
  new Promise((k,b) => toTest(k,b,x))

const another = _things => x => 
  new Promise( (k,b) => _things(k,b,x))

const toTest3 = (k,b,x) => k(x+3)
const toTest4 = (k,b,x) => k(x+4)

promiseToTest(10)
  .then(promiseToTest) // old way chaining
  .then(promiseToTest2) // old way chaining
  .then(another(toTest3)) // new way do not need to write the promise route
  .then(another(toTest4)) // new way do not need to write the promise route
  .catch(console.error)
Aditya
@ezioda004
Oct 05 2018 19:53
const toTest = (k,b,x) => { console.log(x); return k(x+1) }this hurt my eyes
Why not do const toTest = (k,b,x) => console.log(x) || k(x+1);?
psyperl
@psyperl
Oct 05 2018 19:54
oh that's nice yeah .. lol thanks
ok i will keep it green.. at least we know how to log it
psyperl
@psyperl
Oct 05 2018 20:02
not sure if that auto route should be named another, anotherPromise or _promise
which one is better to read?
promiseToFindBetterName()
  .then(another(toFindBetterName)) // 1.
  .then(anotherPromise(toFindBetterName)) // 2.
  .then(_promise(toFindBetterName)) // 3. X
  .then(promise(toFindBetterName)) // 4.
Aditya
@ezioda004
Oct 05 2018 20:06
Generally _something is considered to be private so I wont use that for any variable name (unless its intended to be private)
psyperl
@psyperl
Oct 05 2018 20:07
ok then not 3.
can we name function promise, is that reserved?
not sure if JS can differentiate promise vs Promise
Nope, its not a keyword
psyperl
@psyperl
Oct 05 2018 20:11
yeah i tried it and it seems to work
May Kittens Devour Your Soul
@diomed
Oct 05 2018 20:45
psyperl
@psyperl
Oct 05 2018 20:51
throw SyntaxError("you meant length not lenght?")
Zane Burk
@zaneburk_twitter
Oct 05 2018 21:32
Need help please. Can't get past "make sure each of your label elements has a closing tag"
<label><label for="Indoor"> <input id="Indoor" type="radio" name="indoor-outdoor"> Indoor</label>
<label><label for="Outdoor"> <input id="Outdoor" type="radio" name="indoor-outdoor">Outdoor</label>
</form>
That's my coding
Brad Collins
@BradleyCollins
Oct 05 2018 21:32
looks like you have 2 opening label tags
Zane Burk
@zaneburk_twitter
Oct 05 2018 21:33
That did it! Thank you!!
Brad Collins
@BradleyCollins
Oct 05 2018 21:33
npnp