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
John Nunns
@johnnunns
haha this is true!
JD Tadlock
@jdtdesigns
@johnnunns What's the challenge description again?
John Nunns
@johnnunns
I'll carry you guys in my resume as "Taught by:"
Write a function called "getSquaredElementsAtProperty".

Given an object and a key, "getSquaredElementsAtProperty" returns an array containing all the squared elements of the array located at the given key. 

Notes:
* If the array is empty, it should return an empty array.
* If the property at the given key is not an array, it should return an empty array.
* If there is no property at the key, it should return an empty array.

var obj = {
  key: [2, 1, 5]
};
var output = getSquaredElementsAtProperty(obj, 'key');
console.log(output); // --> [4, 1, 25]

Starter Code :
function getSquaredElementsAtProperty(obj, key) {
  // your code here
}
so my code as of right now passes all the if it's not an array, no property, blah blah
doesn't pass the main req of squaring the numbers though
I've used filter and reduce on the other ones pretty well actually
JD Tadlock
@jdtdesigns
.reduce() would work again for this
John Nunns
@johnnunns
maybe I'm letting the term get in my head i've kind of seen reduce as something that actually makes something smaller :)
ok let me give it a shot
Charles Williams
@cfunkles
@AdelMahjoub I understand what your saying. I was confused about the differences
JD Tadlock
@jdtdesigns
@cfunkles The basic explanation is Bootstrap is CSS
CSS is what Bootstrap is made with
Charles Williams
@cfunkles
@jdtdesigns I understand that
JD Tadlock
@jdtdesigns
so if you know css, then Bootstrap will make sense
which is why i recommend learning css first ;)
John Nunns
@johnnunns
yeah jd with reduce I'm afraid I'm just adding them all together?
I'm squaring them
but not keeping separate
so i'm getting 30 right now
2, 1 ,5 = 30
Charles Williams
@cfunkles
@jdtdesigns I get it now,
I am learning CSS too
John Nunns
@johnnunns
var obj = {
  key: [2, 1, 5]
};

function square(number){
    return number*number;
}

function getSquaredElementsAtProperty(obj, key) {
     var x = [];
    if(!obj[key]){
        return x;
    }else if(obj[key].length === 0){
        return x;
    }else if(!Array.isArray(obj[key])){
        return x;
    }
    return obj[key].reduce(function(a, b){
    return b*b+a
    }, 0);

}

getSquaredElementsAtProperty(obj, 'key')
JD Tadlock
@jdtdesigns
@johnnunns You need to return an array, not a number
so {, 0); should be {, []);
John Nunns
@johnnunns
lets give that a shot
var obj = {
  key: [2, 1, 5]
};

function square(number){
    return number*number;
}

function getSquaredElementsAtProperty(obj, key) {
     var x = [];
    if(!obj[key]){
        return x;
    }else if(obj[key].length === 0){
        return x;
    }else if(!Array.isArray(obj[key])){
        return x;
    }
    return obj[key].reduce(function(a, b){
    return b+a
    }, []);

}

getSquaredElementsAtProperty(obj, 'key')
with the [] i
i'm returning 512
JD Tadlock
@jdtdesigns
are you posting wins or each step? :D
John Nunns
@johnnunns
what's wins?
Janina Pohorecki
@janepohorecka
Can someone please help me fix my navigation bar? This is the second website I have ever made (besides my portfolio page) and I really dont understand my problem.
The mobile view of it.
JD Tadlock
@jdtdesigns
wins as in code that completes the challenge lol @johnnunns
Cameron Stacy
@TheDoctorCam
Running my personal portfolio through codepen on a mobile browser is causing the page to jump when scrolling... can anyone help? http://codepen.io/TheDoctorCam/pen/jyLRWK
@janepohorecka hi, what specific issues are you having?
John Nunns
@johnnunns
the code that will complete the challenge is taking and array like [2, 1, 5] and returning [4, 1, 25]
@jdtdesigns
Janina Pohorecki
@janepohorecka
@TheDoctorCam When I click the three line bar on the top right side of the page, the navigation expands in a funky way. I really dont understand this issue.
Cameron Stacy
@TheDoctorCam
@janepohorecka oh I see it now... it's hard for me to help without seeing your code. But whenever I want a responsive navbar, I use a media query like this :
@media screen and (max-width:680px) {
ul.topnav.responsive {
position: relative;
}
ul.topnav.responsive li.icon {
position: absolute;
right: 0;
top: 0;
}
ul.topnav.responsive li {
float: none;
display: inline;
}
ul.topnav.responsive li a {
display: block;
text-align: left;
}
}
Lallo Vigil
@lalov1
I'm working on the Twitch project and having a little problems with the API. I want to bring back multiple users, but I only get one at a time. Is there a way to get multiple at the same time? https://wind-bow.gomix.me/twitch-api/streams/Day9TV
Janina Pohorecki
@janepohorecka
@TheDoctorCam my code is right here: https://github.com/janepohorecka/Test-Northwest
And thanks!! Let me look over that code
Cameron Stacy
@TheDoctorCam
@janepohorecka just posted my personal portfolio which features this... http://codepen.io/TheDoctorCam/pen/jyLRWK
Tyler Moeller
@TylerMoeller
@lalov1 Unfortunately, no, you'll have to loop through the users array and call the API for each one unless you use the standard Twitch API and get an API key.
JD Tadlock
@jdtdesigns
@johnnunns I just did it using .map() ;)
Tyler Moeller
@TylerMoeller
Was going to say ^^ .map returns a new array. probably a better way to go over .reduce()
JD Tadlock
@jdtdesigns
after reading the challenge rules, i decided .map was better ;)