Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Aug 17 09:32
    User @bjorno43 unbanned @linkin-park
  • Jun 20 21:19
    @bjorno43 banned @shenerd140
  • Apr 25 17:13
    @mstellaluna banned @cmal
  • Jan 08 22:05
    @mstellaluna banned @dertiuss323
  • Nov 07 2018 04:42
    User @texas2010 unbanned @ows-ali
  • Nov 02 2018 16:25
    @texas2010 banned @ows-ali
  • Oct 12 2018 05:50
    @bjorno43 banned @NACH74
  • Oct 05 2018 23:02
    @mstellaluna banned @JomoPipi
  • Sep 16 2018 12:21
    @bjorno43 banned @yash-kedia
  • Sep 16 2018 12:16
    @bjorno43 banned @vnikifirov
  • Sep 05 2018 08:12
    User @bjorno43 unbanned @androuino
  • Sep 05 2018 07:38
    @bjorno43 banned @androuino
  • Aug 23 2018 16:57
    User @bjorno43 unbanned @rahuldkjain
  • Aug 23 2018 16:23
    @bjorno43 banned @rahuldkjain
  • Jul 29 2018 14:13
    User @bjorno43 unbanned @jkyereh
  • Jul 29 2018 01:00
    @bjorno43 banned @jkyereh
  • Jul 10 2018 22:09
    @bjorno43 banned @manafn
  • Jul 06 2018 15:20
    @texas2010 banned @imlegend19
  • Jul 03 2018 12:28
    @bjorno43 banned @vbvmatta
  • Jun 29 2018 13:54
    @bjorno43 banned @OGTechnoBoy
tundeiness
@tundeiness

hi campers. So i'm apparently doing something wrong with this code: the searchValue can't seem to store the value retrieved from the input box. Any help?

<input type="text" size="20" maxlength="30"name="search" placeholder="Search Wikipedia" Id="searchstring" class="sTerm">

that is the html code. The below is the Javascript code:

var searchValue = $('#searchstring').attr('searchstring');

any heads up on this? Thanks.

Sulaiman
@suli-g
@tundeiness The javascript looks like you're trying to get an attribute of "searchstring" from $("#searchstring") and the attribute "searchstring" doesn't exist.
What you want is val(), since you want the value of the input box, and not attr('searchstring') (which would work if your input box had a searchstring="blah" on it)
Chuck Pierce
@ChuckPierce
also id is capitalized it looks like
tundeiness
@tundeiness
@suli-g did .val() once...didn't work that time, but i will try again
@ChuckPierce yes it is sigh
tundeiness
@tundeiness

@suli-g so I did this:

var searchvalue = $('#searchstring').val()

and i'm getting empty string?

Chuck Pierce
@ChuckPierce
is there anything in the input?
Stephen James
@sjames1958gm
@tundeiness Are you running that code in an on change event handle, so it runs after input is in the element?
Onome Sotu
@onomesotu
Good evening all
Can anyone confirm why this code gives me syntax error on the console?
Ghost
@ghost~57b1df1e40f3a6eec05f92a8
@onomesotu Good evening :)
Onome Sotu
@onomesotu
let(a = 2){ console.log(a); //-> 2 }
@Otto-AA hello :smile:
according to YDKJS scope and closure book, it should print 2
Kaz Baig
@kbaig
what are you trying to do
Ghost
@ghost~57b1df1e40f3a6eec05f92a8
@onomesotu The declaration is wrong (SyntaxError: missing variable name)
Onome Sotu
@onomesotu
but i get a syntax error when i test it out on the console, so it's wrong syntax from the author?
Kaz Baig
@kbaig
that's not the syntax for the let keyword
Ghost
@ghost~57b1df1e40f3a6eec05f92a8
Try let a = 2 instead of let (a = 2)
Onome Sotu
@onomesotu
I know the let should go like this
{
    let a = 2;
    console.log(a);
}
Ghost
@ghost~57b1df1e40f3a6eec05f92a8
so in complete:
let a = 2;
if (true) {
   console.log(a);
};
// or
let a = 2;
{
   let b = 3;
   console.log(a, b);
}
console.log(b);  // this will throw an error because b is not declared in this scope
Onome Sotu
@onomesotu
Ghost
@ghost~57b1df1e40f3a6eec05f92a8
didn't know that the second one without if actually works ^^
Onome Sotu
@onomesotu
@Otto-AA I understand all that :smile: I was just wondering if this was correct becuase it didn't work on the console
@Otto-AA Yes, it works without an If
Ghost
@ghost~57b1df1e40f3a6eec05f92a8

But, there's a problem. The let-statement form is not included in ES6. Neither does the official Traceur compiler accept that form of code.

I guess that's the reason it doesn't work

(also from your tutorial)
Onome Sotu
@onomesotu
@kbaig @Otto-AA thanks.. I checked but just wanted to make sure
CamperBot
@camperbot
onomesotu sends brownie points to @kbaig and @otto-aa :sparkles: :thumbsup: :sparkles:
:cookie: 478 | @kbaig |http://www.freecodecamp.org/kbaig
:cookie: 404 | @otto-aa |http://www.freecodecamp.org/otto-aa
Onome Sotu
@onomesotu
@Otto-AA I wonder why he commented print 2 instead of saying it would throw a syntax error
A-J Roos
@Asjas

@onomesotu Again, the guy continues to explain why it doesn't work and how to get it to work.
`
We have two options. We can format using ES6-valid syntax and a little sprinkle of code discipline:

But, tools are meant to solve our problems. So the other option is to write explicit let statement blocks, and let a tool convert them to valid, working code.

So, I built a tool called "let-er" [^note-let_er] to address just this issue. let-er is a build-step code transpiler, but its only task is to find let-statement forms and transpile them. It will leave alone any of the rest of your code, including any let-declarations. You can safely use let-er as the first ES6 transpiler step, and then pass your code through something like Traceur if necessary.
`

If you read what is actually in the book you'll get the answers in there
Onome Sotu
@onomesotu
@Asjas I got it in the end, but here I just think it's weird that he commented output of 2 in the code..instead of just saying syntax error..
let (a = 2) {
    console.log( a ); // 2
}
A-J Roos
@Asjas
Yeah I have it opened.
Onome Sotu
@onomesotu
ok good
@Asjas but thanks, I will read up on performance now :)
CamperBot
@camperbot
onomesotu sends brownie points to @asjas :sparkles: :thumbsup: :sparkles:
:cookie: 312 | @asjas |http://www.freecodecamp.org/asjas
A-J Roos
@Asjas
No i didn't mean performance. I meant read the entire part of Implicit vs Explicit Blocks. Top to bottom. The book gives the answers
Onome Sotu
@onomesotu
yeah.. found that out. thanks Use original ES6 syntax or trans-pile using let-er
Alan Price
@alanpaulprice
Hey guys, I was wondering if anyone could help me figure out why there is an extra, unwanted delay before my fade in animation is happening. It's on the keybinds info at the bottom of the page: https://alanpaulprice.github.io/metronome/
I have it set to a 1.5 second delay, but it should be fading in at the same time as the other info on the left
Tom
@moT01
@alanpaulprice 190-193 in the css
i think