These are chat archives for FreeCodeCamp/HelpJavaScript

14th
Mar 2018
Tiago Correia
@tiagocorreiaalmeida
Mar 14 2018 00:09
that one broke my heart @JLuboff ahaha
i don't konw,what'wrong?
var gloveBoxContents = myStorage.car["glove box"];
var myStorage = {
"car": {
"inside": {
"glove box": "maps",
"passenger seat": "crumbs"
},
"outside": {
"trunk": "jack"
}
}
};
abraham anak agung
@padunk
Mar 14 2018 03:57
@LinHuijuan you forget inside
啊吖嗄
@LinHuijuan
Mar 14 2018 03:57
thanks @padunk
CamperBot
@camperbot
Mar 14 2018 03:57
linhuijuan sends brownie points to @padunk :sparkles: :thumbsup: :sparkles:
:cookie: 475 | @padunk |http://www.freecodecamp.org/padunk
Jason Luboff
@JLuboff
Mar 14 2018 15:14
@tiagocorreiaalmeida It's all in good fun! I'll show you that solution if you'd like (its for SteamRoller)
Markus Kiili
@Masd925
Mar 14 2018 15:17
@JLuboff Hi.
Jason Luboff
@JLuboff
Mar 14 2018 15:17
@Masd925 Morning!
595262023
@595262023
Mar 14 2018 15:59
168
Jason Luboff
@JLuboff
Mar 14 2018 16:03
168 what?
Blauelf
@Blauelf
Mar 14 2018 16:04
A random number posts a random number. This must be Pi day, somewhere around the 638,373,331st decimal digit.
Jason Luboff
@JLuboff
Mar 14 2018 16:04
Ah... good ol' Pi day
So a bot is having his Pi
Blauelf
@Blauelf
Mar 14 2018 16:05
I guess our random friend is mistaking brownie points (which do exist) for problem numbers (which don't exist, of course)
Comparing their to my regular ? lets me assume they are probably Chinese, less likely Japanese.
Jason Luboff
@JLuboff
Mar 14 2018 16:07
The question mark did look odd
Kaz Baig
@kbaig
Mar 14 2018 16:09
@JLuboff @Blauelf http://www.codetable.net/decimal/65311 if you were wondering what the character is lol
jusgoose
@gusd773
Mar 14 2018 16:10
anybody got links on how to add sections to my page? I want some scroll action but it's only got the header section in the body
Jason Luboff
@JLuboff
Mar 14 2018 16:10
Fancy
Blauelf
@Blauelf
Mar 14 2018 16:10
Never questioned that.
Kaz Baig
@kbaig
Mar 14 2018 16:11
In the character code table, it's right next to Japanese letters so there's that @Blauelf @JLuboff
Blauelf
@Blauelf
Mar 14 2018 16:11
Those full-width characters that closely resemble ours tend to appear when Chinese or Japanese use Latin characters. Here on chat, there are more Chinese, there's even a channel just for Chinese.
You're right, next to that are Japanese syllable characters, followed by Korean Hangul (also a syllable alphabet, more logical in character composition than the Japanese)
Kaz Baig
@kbaig
Mar 14 2018 16:14
Yeah in terms audience they're more likely to be Chinese
I guess we'll never know
Jason Luboff
@JLuboff
Mar 14 2018 16:15
...or will we?
@Blauelf As a physicist (or I think you are?), I imagine you're pretty bummed about the death of Dr. Hawking?
Blauelf
@Blauelf
Mar 14 2018 16:18
Well, he had quite a few more years than everybody expected.
Jason Luboff
@JLuboff
Mar 14 2018 16:19
True
Kaz Baig
@kbaig
Mar 14 2018 16:23
@Blauelf wasn't he expected to get the Nobel for Hawking radiation?
Sad that it isn't given posthumously
Blauelf
@Blauelf
Mar 14 2018 16:23
@gusd773 What do you mean with "sections" and "scroll action"? Parallax scrolling? Different backgrounds?
jusgoose
@gusd773
Mar 14 2018 16:26
@Blauelf diff backgrounds
Blauelf
@Blauelf
Mar 14 2018 16:27

@kbaig Well, it has been. https://www.nobelprize.org/nobel_prizes/facts/

Posthumous Nobel Prizes

From 1974, the Statutes of the Nobel Foundation stipulate that a Prize cannot be awarded posthumously, unless death has occurred after the announcement of the Nobel Prize. Before 1974, the Nobel Prize has only been awarded posthumously twice: to Dag Hammarskjöld (Nobel Peace Prize 1961) and Erik Axel Karlfeldt (Nobel Prize in Literature 1931).

Following the 2011 announcement of the Nobel Prize in Physiology or Medicine, it was discovered that one of the Medicine Laureates, Ralph Steinman, had passed away three days earlier. The Board of the Nobel Foundation examined the statutes, and an interpretation of the purpose of the rule above led to the conclusion that Ralph Steinman should continue to remain a Nobel Laureate, as the Nobel Assembly at Karolinska Institutet had announced the 2011 Nobel Laureates in Physiology or Medicine without knowing of his death.

@gusd773 To have different backgrounds, your content needs to be in different block elements (e.g. divs).
Chris
@ConnectCodes
Mar 14 2018 17:39
Hi guy, Stuck on Exact Change challenge. I changed everything to cents to avoid floating. I have two while loops but they make page non-responsive , nd I dont udrestand why (I turned off javascript in the codepen link). For loop doesn’t work either. Is while loop a viable option ?
https://codepen.io/Codeconnect/pen/dZQygY?turn_off_js=true
Dardan Demiri
@dardandmr
Mar 14 2018 17:43
You have an infinite loop @ConnectCodes
Blauelf
@Blauelf
Mar 14 2018 17:44

I used recursion with for loops, but for matching my own challenge, that is returning a value of $0.30 when I have quarters and dimes only.

Most people use greedy algorithms that would pick a quarter and fail on the last five cents, while it is possible to return three dimes.

Any for loop can be expressed as a while loop, so while loops are an option, and you could make any kind of loop infinite if you mess up the conditions.

Chris
@ConnectCodes
Mar 14 2018 17:48
@Blauelf I see. When I tested my inner while loop with condition while(currencyAmount[i] !== localCounter) it worked but the outer while loop is the problem. Maybe problem isi—? I am confused.
 while(changeCent !== totalCounter){
        var localCounter = 0;
        while(currencyAmount[i] !== localCounter){
              localCounter += valueCurrency[i];
              }
        totalCounter += localCounter;
        result.push(localCounter);
        i--;
    }
Dardan Demiri
@dardandmr
Mar 14 2018 17:51
your localCounter
Blauelf
@Blauelf
Mar 14 2018 17:53
!== in combination with directions always looks weird. If a value you test for is going up, your condition should probably be more like <.
Chris
@ConnectCodes
Mar 14 2018 18:00
@Blauelf You mean changeCent > totalCounter? Wouldnt that make totalCounter just short of the changeCent?
Chris
@ConnectCodes
Mar 14 2018 18:06
@dardandmr hmm could you explain a little?
jusgoose
@gusd773
Mar 14 2018 18:56

@Blauelf

<body>
    <header>
        <div class= "row">
            <div class= "logo">
                <img src="@JUSGOOSE.jpg">

                <ul class="main-nav">
                    <li class="active"><a href="">HOME</a></li>
                    <li><a href="">MUSIC</a></li>
                    <li><a href="">ABOUT</a></li>
                    <li><a href="">NEWS</a></li>
                    <li><a href="">CONTACT</a></li>
                </ul>
            </div>


    </section>
        <div class="mainText">
            <h1>  jusgoose </h1>
        </div>


    </header>
    </div>        
    <section class="parallax">
        <div class="parallaxInner"></div>


<a href="javascript:void(0)" title="Go To Top" id="scroll" style="display:none;">
    <span></span>
</a>

</body>
</html>
//css//
*
{
    margin:0;
    padding: 0;
}
body{
    background-image: linear-gradient(rgba(0,0,0,.5), rgba(0,0,0,.5)), url(jusgooseheader.jpg);
    background-size: cover;
    background-position: center;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5);
    margin:50px    50px;

}

.main-nav{
    float:right;
    list-style: none;
    margin-top: 30px;
}
.main-nav li{
    display: inline-block;

}

.main-nav li a{
    color: white;
    text-decoration: none;
    padding: 5px 20px;
    font-family:Impact, Charcoal, sans-serif;
    font-size:20px;
    -webkit-text-stroke: 1px black;
}

.main-nav li.active a{
    border: 5px solid white;

}

.main-nav li a:hover{
    border: 1px solid white;


}

.logo img{

    height: 175px;
    width: 175px;
    margin-top: 10px;
    margin-left: 200px;
    border: 3px solid black;

}

.row{
    max-width: 1200px;
    margin: auto;
}

.mainText{

    padding: 10px 20px;
    border: 10px solid white;
    margin-top: 90px;
}

.mainText h1{
    text-align: center;
    font-size: 100px;
    text-transform: uppercase;
    color: white;
    font-family: Impact, Charcoal, sans-serif;
    -webkit-text-stroke: 4px black;
    letter-spacing: 5px;
}



#scroll{
    position: fixed;
    right: 10px
    bottom: 10px;
    height: 50px;
    width: 50px;
    background-color:  blue;
    border-radius: 60px;

}

#scroll span{
    position: absolute;
    top:50%;
    left:50%;
    margin-left: -8px;
    margin-top: -12px;
    border: 8px solid transparent;
    border-bottom-color: white;


}

#scroll:hover{
    background-color: cyan;
    opacity: 1;
    filter: "alpha(opacity=100)";
}

.parallax{
    background: url(jusgoose2.jpg) cover;

}

I am trying to put the background to a url in my css for the parallax div but it wont show up

Jason Luboff
@JLuboff
Mar 14 2018 19:03
It's partial becuase unless jusgoose2.jpg exists in the same root folder as your css and html page...it doesn't know where the file is
jusgoose
@gusd773
Mar 14 2018 19:27
@JLuboff it's def in the same folder
Tiago Correia
@tiagocorreiaalmeida
Mar 14 2018 20:56
hello everyone
Dardan Demiri
@dardandmr
Mar 14 2018 20:56
hello @tiagocorreiaalmeida
Jason Luboff
@JLuboff
Mar 14 2018 20:57
Afternoon
Tiago Correia
@tiagocorreiaalmeida
Mar 14 2018 20:58
so anyone interested in building a toggl clone? I get lazy If I do it alone having a partner forces me to do work :D
Jason Luboff
@JLuboff
Mar 14 2018 21:00
Whats toggl?
Tiago Correia
@tiagocorreiaalmeida
Mar 14 2018 21:01
it's a time tracker
give it a look
Jason Luboff
@JLuboff
Mar 14 2018 21:02
Interesting
Tiago Correia
@tiagocorreiaalmeida
Mar 14 2018 21:10
@JLuboff interested ?
Jason Luboff
@JLuboff
Mar 14 2018 21:10
No time unfortunately
Kaz Baig
@kbaig
Mar 14 2018 21:27
@tiagocorreiaalmeida might have some luck in the LetsPair room
Tiago Correia
@tiagocorreiaalmeida
Mar 14 2018 21:28
https://jsfiddle.net/48Lxbstx/2/ can someone give a look at this ? im failing some hidden test's so I have no idea whta I might be missing
Brad
@bradtaniguchi
Mar 14 2018 21:31
I am already working on a toggl clone XD, but its an angular-firebase project haha
Tiago Correia
@tiagocorreiaalmeida
Mar 14 2018 21:31
well If I knew before we could have gone the node/mongo path
Brad
@bradtaniguchi
Mar 14 2018 21:33
I mean to transition to use an alternate backend is doable, I just more or less started, and already ran into problems with the database design and firestore capabilities
Jason Luboff
@JLuboff
Mar 14 2018 21:34
Psh. Make it more challenging, go with SQL instead :P
Tiago Correia
@tiagocorreiaalmeida
Mar 14 2018 21:34
@JLuboff give a look in the jsfidle if you can above
or this bot will beat me to death :(
@bradtaniguchi if you wanna pair just let me know
Brad
@bradtaniguchi
Mar 14 2018 21:34
I could of done it with SQL, but I liked the idea of building the entire app front-end for real time
Jason Luboff
@JLuboff
Mar 14 2018 21:35
The SQL part was a joke. I'm building my current app with it and it's much more difficult than using say Mongo would be. But eh. I'm getting it done
And its good practice
Tiago Correia
@tiagocorreiaalmeida
Mar 14 2018 21:36
I used to work with mysql when I did a few projects with php 2 / 3 years ago
Jason Luboff
@JLuboff
Mar 14 2018 21:36
I'm designing my database as I go..so thats slightly problematic lol
Tiago Correia
@tiagocorreiaalmeida
Mar 14 2018 21:36
with sql that's quite problematic :D
Brad
@bradtaniguchi
Mar 14 2018 21:37
I mean SQL is pretty good for most use cases when designed well.
Jason Luboff
@JLuboff
Mar 14 2018 21:37
@tiagocorreiaalmeida So you pass the provided tests but not the hidden?
Tiago Correia
@tiagocorreiaalmeida
Mar 14 2018 21:38
yeah indeed
Jason Luboff
@JLuboff
Mar 14 2018 21:38
...my design may not be well.. lol But I can refactor it later. It's all in development right now
Tiago Correia
@tiagocorreiaalmeida
Mar 14 2018 21:39
I think I got their idea right, I made a basic process to check the unique words that exist in both sides store the array position, the ammount of times and the last match index plus one position to know where I have to slicei t later on
Jason Luboff
@JLuboff
Mar 14 2018 21:39
Ya seems like oyu're going the right path
You account for no match in words
Tiago Correia
@tiagocorreiaalmeida
Mar 14 2018 21:40
so what's wrong god
Jason Luboff
@JLuboff
Mar 14 2018 21:41

I think this:

matches = matches.sort((a,b)=> a[1] == b[1] ? a[0] > b[0] : a[1] < b[1]);

Is accounting for if there is an equal match, to get the first match...?

Tiago Correia
@tiagocorreiaalmeida
Mar 14 2018 21:41
yeah indee
if they match on unique words that existe on the array
order them by the index array
you know what @JLuboff open codefights
I give you the solution ofr the first exercise and you get into the second one maybe will be easier to see the content on the platform
im just gonna spam @alpox he will probably spot an issue on my code :D
Adel
@AdelMahjoub
Mar 14 2018 21:43
@tiagocorreiaalmeida you have solved that challenge last time right ? want another solution ?
Tiago Correia
@tiagocorreiaalmeida
Mar 14 2018 21:44
no I solved the first one
this one I got stuck on this part and went to sleep since it was allready later
and hey brownies monster
Jason Luboff
@JLuboff
Mar 14 2018 21:45
Get @AdelMahjoub to help haha
Kaz Baig
@kbaig
Mar 14 2018 21:45
pshh that guy will just do it himself in one night
Adel
@AdelMahjoub
Mar 14 2018 21:47
I found a 1k pages book about algorithms, I read the introduction, and I'm still thinking should I start reading it or not, because if I start reading it I'll switch to caveman mode
and that's not good :laughing:
1k pages, that's damn a lot
Jason Luboff
@JLuboff
Mar 14 2018 21:48
If you have time to read 1000 page book on algorithms..you need to get a job :P
Adel
@AdelMahjoub
Mar 14 2018 21:48
you made a very good point @JLuboff
Jason Luboff
@JLuboff
Mar 14 2018 21:49
@AdelMahjoub You still looking for one?
Adel
@AdelMahjoub
Mar 14 2018 21:49
not really looking, still in hobbiest mode
Jason Luboff
@JLuboff
Mar 14 2018 21:50
Ah
Tiago Correia
@tiagocorreiaalmeida
Mar 14 2018 21:50
@AdelMahjoub can you give a look to the challenge ?:D
I can give you some real brownies
:D
ahaha
Adel
@AdelMahjoub
Mar 14 2018 21:50
some not declared tasks here and there
Tiago Correia
@tiagocorreiaalmeida
Mar 14 2018 21:51
whato do you mean?
Adel
@AdelMahjoub
Mar 14 2018 21:51
@tiagocorreiaalmeida about some work, not declared or non official, no contract
Jason Luboff
@JLuboff
Mar 14 2018 21:52
paid under the table as the saying goes
Tiago Correia
@tiagocorreiaalmeida
Mar 14 2018 21:52
got it :D
Adel
@AdelMahjoub
Mar 14 2018 21:52
yes exactly
Brad
@bradtaniguchi
Mar 14 2018 21:53
The moment you find a bug that makes all generated codes the same >.>
Adel
@AdelMahjoub
Mar 14 2018 21:53
@tiagocorreiaalmeida I'll take a look at the challenges, first I have to catch up to warm up :laughing:
Tiago Correia
@tiagocorreiaalmeida
Mar 14 2018 21:54
ahahaha sure, if you are one codefights I can tell you the bot im fighting and giving the first challenge solution
I dont evne know why im fighting bot's, but I guess its cause of the timing so I wont get lazy
Blauelf
@Blauelf
Mar 14 2018 22:03
@ConnectCodes I haven't analyzed your code. But if you increment something, you should have some kind of upper bound, not just a not-equal. In case you missed the equal, you wouldn't be able to stop otherwise.
Tiago Correia
@tiagocorreiaalmeida
Mar 14 2018 22:12
have you given it a look @AdelMahjoub ?
Adel
@AdelMahjoub
Mar 14 2018 22:21
@tiagocorreiaalmeida still on previous challenges, which number it is
Tiago Correia
@tiagocorreiaalmeida
Mar 14 2018 22:21
its a bot fight
wizelinebot
its the second exercise on that bot
alpox
@alpox
Mar 14 2018 22:24
@tiagocorreiaalmeida Sry, not today anymore :D i'm going to bed
Tiago Correia
@tiagocorreiaalmeida
Mar 14 2018 22:25
no worries @alpox see you tomorrow :)
alpox
@alpox
Mar 14 2018 22:25
@tiagocorreiaalmeida See you :)
Jason Luboff
@JLuboff
Mar 14 2018 22:33
Damn Find and Repalce
Adel
@AdelMahjoub
Mar 14 2018 23:37
@tiagocorreiaalmeida can you test this solution, if I skip the first part I could not come back to it
/**
 * 
 * @param {Array<Array<string>>} conversations 
 * @param {Array<string>} currentConversation 
 * @returns {Array<string>}
 */
function chatBot(conversations, currentConversation) {

    /** @type {Array<{index: number, count: number, words: Array<string>} */
    let matches = [];

    /** @type {Array<string>} */
    let conversationToKeep = [];

    /** @type {Array<string>} */
    let missingWords = [];

    /** @type {string} */
    let lastMatchingWord = '';

    conversations.forEach((conversation, index) => {
        const words = Array.from(new Set(conversation.filter(word => currentConversation.indexOf(word) >= 0))); /* Keep only unique matching values */
        if(words.length) {
            matches.push({index, count: words.length, words});
        }
    });

    /* No matching words, return current conversation as it is*/
    if(!matches.length) {
        return currentConversation;
    }

    /* Sort by Descending word count, Ascending index */
    matches.sort((a ,b) => {
        if(!(b.count - a.count)) {
            return a.index - b.index
        }
        return b.count - a.count;
    });

    conversationToKeep = conversations[matches[0].index];
    lastMatchingWord = matches[0].words[matches[0].words.length - 1]; /* Last matching word */
    missingWords = conversationToKeep.slice(conversationToKeep.lastIndexOf(lastMatchingWord) + 1);

    return currentConversation.concat(missingWords);
}
Brian
@BrianCodes33
Mar 14 2018 23:42
any react devs