These are chat archives for FreeCodeCamp/Help

21st
Nov 2017
Ismail Hozain
@ismailhozain
Nov 21 2017 00:19
hey guys is it possible to pass the result of a javascript function into an html and/or a css function?e.g. when button clicked -change image
Johnny
@JohnnyBizzel
Nov 21 2017 02:17
@ismailhozain I don't know what a HTML or CSS function is. You can change the image in JavaScript as it will update the DOM.
zhangsnaan
@zhangsnaan
Nov 21 2017 05:18
image.png
咋改
Ken Haduch
@khaduch
Nov 21 2017 05:22
@zhangsnaan - which lesson is that?
zhangsnaan
@zhangsnaan
Nov 21 2017 05:26
?
Ken Haduch
@khaduch
Nov 21 2017 05:27
@zhangsnaan - what is the name of the lesson that you posted the image of the screenshot?
@zhangsnaan - oh, I think I might see the problem - you need a closing } on your style declaration for .red-text - you have the opening {, then your two CSS properties, but no closing }.
Ken Haduch
@khaduch
Nov 21 2017 05:35
@zhangsnaan - in other words:
<style>
    .red-text {
        color: red;
        font-size: 16px;
    } /* <==== you need this closing curly brace on your style declaration */
</style>
stone
@stone54240
Nov 21 2017 09:03
@zhangsnaan 里边两个p标签,需要同时对两个标签设定字体大小,你的第二个品标签没有设置类属性。
stone
@stone54240
Nov 21 2017 09:09

@zhangsnaan 额……不要给第二个p加类属性……所以你需要这个写

<style>

<style>
p {
<style>
p {
font-size:16px;
}
</style>
jianjianhao
@jianjianhao
Nov 21 2017 09:28
<script>
$(document).ready(function() {
$("#target1").css("color", "red");
$("#target4").html("<em>target4</em>");
});
</script>
Jack Ray
@JackWithRose
Nov 21 2017 12:17
html的38关是不是有问题啊
写对了还不让我过啊
<form action="/submit-cat-photo">
<input type="text" placeholder="cat photo URL" required>
<button type="submit">Submit</button>
<lable><input type="radio" name="indoor-outdoor">indoor</lable>
<lable><input type="radio" name="indoor-outdoor">outdoor</lable>
</form>
你的页面上应该有两个单选按钮元素。
设置你的单选按钮的name属性为indoor-outdoor。
你的两个单选按钮中的每一个都应该嵌套进它自己的label元素中。
确保你的每一个label元素都有一个结束标记。
应该有一个indoor单选按钮。
给你的表单添加两个单选按钮,一个叫indoor,另一个叫outdoor。
rscales02
@rscales02
Nov 21 2017 13:04
$('.game').click(function() {
        var userClick = $(this).attr('id');
        clickSound(userClick);

        clearInterval(repeatDelay);

        console.log(repeatDelay);
        repeatDelay = setInterval(function(){
            console.log('click');
            loseTimer(combination);
        }, dTime);
I am trying to reset this interval with each user click, it seems to just call a new instance of repeatDelay with each call... thoughts?
gao123456
@gao12345
Nov 21 2017 14:06

<style>
.red-text {
color: red;
}

p {
font-size: 16px;
}
</style>

<h2 class="red-text">CatPhotoApp</h2>

<p class="red-text">在大家心目中,猫是慵懒的可爱的化身,它可以睡饱了再起来吃饭,可以逗趣小耗子,可以卖得了萌,使得了坏,这样百变的小怪兽就集结在一只宠物上,怎能不惹人怜爱。</p>

<p>养动物有的时候,就是介于爱与恨之间,当你钦羡别人萌宠这么可爱的时候,你一定没有想过,狗狗和猫猫会到处拉屎,甚至会屯老鼠,啃鞋子,用爪子爬门,你不理它,它就挠你,你要对它发脾气,它会比你更来劲。所以,狗猫慎入,没有一定的准备,切勿随便去侍养动物。它们一旦认定你了,你就是它们的主人,如果你抛弃它们,它们必定心中重创。</p>
把副标题的字体设置为Sans-serif,你可以使用下面的CSS:
h2 {
font-family: Sans-serif;
}
任务:让所有的p元素都使用Monospace字体。
该怎样写呢,请教一下
看不懂的

Albert Cardona II
@daddycardona
Nov 21 2017 15:05
what up ayll and I have no idea what that says @gao12345
for @kbaig here is the video I was working on video
This is what I haves so far but don't know how to make it destructured.

const greeting = 'itadakimasu';
// change code below this line

const length = greeting.split().length(); // change this
// change code above this line
console.log(length); // should be using destructuring

Kaz Baig
@kbaig
Nov 21 2017 15:15
@daddycardona Morning! Oh didn't know it was for a vid
@karinafarina general note: length is not an array function, just a property
so you would want length and not length()
karinafarina
@karinafarina
Nov 21 2017 15:17
Oh, thanks
Kaz Baig
@kbaig
Nov 21 2017 15:17
remember, destructuring is done using the spread operator ...
it 'spreads' the the contents into the object you're spreading into
in this case, you want to spread a spring into an array
karinafarina
@karinafarina
Nov 21 2017 15:18
spring?
Kyle Holm
@thekholm80
Nov 21 2017 15:18
omg i solved it but those are some really crappy instructions
Kaz Baig
@kbaig
Nov 21 2017 15:18
string*
karinafarina
@karinafarina
Nov 21 2017 15:18
string, right, sorry
Moisés Man
@moigithub
Nov 21 2017 15:18

exaple of Object destructuring

myObj={name: 'booo', ge: 100};
let  {name}= myObj;

soo if u do console.log(name) u will see booo
let {name}= myObj; is the same as let name = myObj.name

Kaz Baig
@kbaig
Nov 21 2017 15:19
const string = 'hello';
const destructured = [...string]; // ['h', 'e', 'l', 'l', 'o']
Does that help?
Moisés Man
@moigithub
Nov 21 2017 15:21
spread operator is NOT destructuring
Kyle Holm
@thekholm80
Nov 21 2017 15:21
but it's what they're looking for
really poorly written
Moisés Man
@moigithub
Nov 21 2017 15:21
nop
karinafarina
@karinafarina
Nov 21 2017 15:21
this worked but i don't think it's destructuring
const length = greeting.split().length;
so how would that be rewritten destructured, @kbaig
Moisés Man
@moigithub
Nov 21 2017 15:22
example of array destructuring...
arr=[1,2,3]
let [a,b,c]=arr
is the same as
let a =arr[0]
let b =arr[1]
let c =arr[2]
on javascript everything inherit from native objects
soo..
if u have let txt = "something"
txt will inherit from String native object
soo it will have ,methods and properties. like length
Kaz Baig
@kbaig
Nov 21 2017 15:24
@daddycardona You prob know this - I'm only a couple mins into the video - but here's a tip: You can double click the cross to copy paste the pattern down the col instead of dragging. It'll go down till it runs out of consecutive rows
Moisés Man
@moigithub
Nov 21 2017 15:25

ie:

txt = {
    valueOf() {return "aa"}, 
     length : 2
}

soo if u wanna destructure.. (extract) length property..
following the above example...
let {length} = txt

Kyle Holm
@thekholm80
Nov 21 2017 15:26
ah, got it
so yeah, can use object destructuring to pull the length key off of that object
Kaz Baig
@kbaig
Nov 21 2017 15:26
@karinafarina @moigithub oh durr you're right I messed my terms up
haha
Kyle Holm
@thekholm80
Nov 21 2017 15:26
still not really explained well in the lesson
Moisés Man
@moigithub
Nov 21 2017 15:26
yep
karinafarina
@karinafarina
Nov 21 2017 15:27
So is what I had destructuring?
const length = greeting.split().length;
Kaz Baig
@kbaig
Nov 21 2017 15:27
no there is no destructuring there
Moisés Man
@moigithub
Nov 21 2017 15:27
nope.. that will be es5 way to get the length value
destructuring is es6
karinafarina
@karinafarina
Nov 21 2017 15:28
So how would Iuse desgtructuring for that?
Kyle Holm
@thekholm80
Nov 21 2017 15:29
the answer is above, scroll up
Moisés Man
@moigithub
Nov 21 2017 15:29
i dunno how to explain in less technical words.. im n00b :crying_cat_face:
Kyle Holm
@thekholm80
Nov 21 2017 15:30
i don't think they ever explained prototype in the beta lessons
so they're kind of using knowledge they never gave
Kaz Baig
@kbaig
Nov 21 2017 15:31
Another reason to learn ES5 first
@moigithub oh idk why I assumed we have to use array destructuring LOL so I was like wait...why would I want that
But I also just realized among my confusion that you can spread strings so that's nice
Kyle Holm
@thekholm80
Nov 21 2017 15:33
@kbaig haha me too! never using split() again lol
karinafarina
@karinafarina
Nov 21 2017 15:38
Got it, cool, thanks guys.
Kyle Holm
@thekholm80
Nov 21 2017 15:39
do you understand why it works? @karinafarina
karinafarina
@karinafarina
Nov 21 2017 15:40
I think I get it, but if you want to explain it might deepen my understanding and I would welcome that
Kyle Holm
@thekholm80
Nov 21 2017 15:40
when you console.log(greeting) it only outputs the value of that variable
but behind the scenes there's a lot more attached to that variable
each 'string' is actually an object
inside that object there's some different things
in this case, we're after the length property inside that object
so we can destructure { } a string to access the different properties within that object
like { length }
Darren
@DarrenfJ
Nov 21 2017 15:43
morning fCC
Kyle Holm
@thekholm80
Nov 21 2017 15:43
@DarrenfJ :wave:
Darren
@DarrenfJ
Nov 21 2017 15:43
hey @daddycardona :wave:
hey @thekholm80 :wave: again ;)
karinafarina
@karinafarina
Nov 21 2017 15:49
Thank you @thekholm80 , that makes a lot ofsense
CamperBot
@camperbot
Nov 21 2017 15:49
karinafarina sends brownie points to @thekholm80 :sparkles: :thumbsup: :sparkles:
:star2: 1596 | @thekholm80 |http://www.freecodecamp.org/thekholm80
Ken Haduch
@khaduch
Nov 21 2017 15:59
@DarrenfJ - good morning....
Stephen James
@sjames1958gm
Nov 21 2017 16:00
@DarrenfJ :wave:

let a = 8, b = 6;
// change code below this line

// change code above this line
console.log(a); // should be 6
console.log(b); // should be 8

from the examples in this exercise I can't figure it out
Darren
@DarrenfJ
Nov 21 2017 16:15
morning peeps @khaduch @sjames1958gm
Darren
@DarrenfJ
Nov 21 2017 16:24
@karinafarina oh wow that one looks like fun.. i did these a while ago and as @thekholm80 saiud above found the instructions very looseygoosey..
I'll have to go back and check a few out and get back into that groove..
Kaz Baig
@kbaig
Nov 21 2017 16:24
@karinafarina array destructuring:
const arr = [1, 2, 3];
const [a, b, c] = arr;
a // 1
b // 2
c // 3
similarly,
let [a, b] = [1, 2];
[a, b] = [b, a];
a // 2
b // 1
karinafarina
@karinafarina
Nov 21 2017 16:38
that did it, @kbaig !
Darren
@DarrenfJ
Nov 21 2017 16:38
hey @daddycardona thanks for the vid i can always use more excel practice...
CamperBot
@camperbot
Nov 21 2017 16:38
darrenfj sends brownie points to @daddycardona :sparkles: :thumbsup: :sparkles:
:cookie: 493 | @daddycardona |http://www.freecodecamp.org/daddycardona
Darren
@DarrenfJ
Nov 21 2017 16:39
also, yer vlog! i had forgotten about that.. congrats
Kaz Baig
@kbaig
Nov 21 2017 16:39
excel is bae
that I don't get to use anymore because there's an opposition to it at work
Darren
@DarrenfJ
Nov 21 2017 16:40
I had a VP once upon a time that challenged us to build stuff in excel before we tried to have dev reams code anything...
wow.. thanks for the code @kbaig
CamperBot
@camperbot
Nov 21 2017 16:40
:cookie: 445 | @kbaig |http://www.freecodecamp.org/kbaig
darrenfj sends brownie points to @kbaig :sparkles: :thumbsup: :sparkles:
Kyle Holm
@thekholm80
Nov 21 2017 16:40
I've done some pretty awesome things with VBA in excel
Darren
@DarrenfJ
Nov 21 2017 16:40
but holy wow the write-up does not even suggest that approach lol!
Kyle Holm
@thekholm80
Nov 21 2017 16:40
and some things i'm not proud of
Darren
@DarrenfJ
Nov 21 2017 16:41
yah, i used to be able to circa 2005 or 6 or 7 or something
like everything.. all that knowledge is lost to the wind now ;)
Kyle Holm
@thekholm80
Nov 21 2017 16:41
i read that as "lost to windows 8"
Darren
@DarrenfJ
Nov 21 2017 16:41
that would make more sense lol!
Kaz Baig
@kbaig
Nov 21 2017 16:42
If I'm not mistaken, when the MS Office team did their AMA a couple years ago on Reddit, they said that the next iteration was going to have JS support instead of or in addition to VBA
Kyle Holm
@thekholm80
Nov 21 2017 16:42
oh, interesting
Kaz Baig
@kbaig
Nov 21 2017 16:42
It was JS or Java...it was before I knew there was a difference lol
Kyle Holm
@thekholm80
Nov 21 2017 16:42
i don't miss VBA at all
Darren
@DarrenfJ
Nov 21 2017 16:46
yah.. i just remember thinking it was cool to be able rework macros if you had to
ok gotta run to a meeting
thanks for the chat @thekholm80 @kbaig
CamperBot
@camperbot
Nov 21 2017 16:46
darrenfj sends brownie points to @thekholm80 and @kbaig :sparkles: :thumbsup: :sparkles:
api offline
:star2: 1597 | @thekholm80 |http://www.freecodecamp.org/thekholm80
Darren
@DarrenfJ
Nov 21 2017 16:47
be back later
Darren
@DarrenfJ
Nov 21 2017 19:19
back
oh man.. quiet in thee ole tumbleweedTown ;)
Kaz Baig
@kbaig
Nov 21 2017 19:24
rip
Darren
@DarrenfJ
Nov 21 2017 22:19
:D
Kyle Holm
@thekholm80
Nov 21 2017 22:20
:zzz: