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
Marianissimus
@Marianissimus
it's ok, you're learning
we all are
what's with the second loop? it's not doing anything.
Javier Pons
@JavierPons
@Marianissimus not yet
@Marianissimus if repite has a new array with duplicates I won't to check it and print the first num
but it was half writen
:smile:
Javier Pons
@JavierPons

```
let repite = [];
function firstDuplicate(a) {

for (let i = 1; i<a.length; i++) {

if (a[i] === a[i+1]) {
    repite.push(a[i]);   
    } else {
        return -1;
    }
}

};

for (let j = 1; j<repite.length; j++) {

return repite[j][0];

};

any comment? sometimes is given a lot of -1
Marianissimus
@Marianissimus
ok, what are the requirements for this function? if you need to return the first duplicate, it might not work if the items are not in sequence inside the arrey
Javier Pons
@JavierPons
@Marianissimus mmm...
Marianissimus
@Marianissimus
so you either need a double loop (one inside the other), or another js method. try indexOf / lastIndexOf, or map, reduce, filter, something in this category
Javier Pons
@JavierPons
:+1: :smile:
Marianissimus
@Marianissimus
@JavierPons here's a present for you; try to use console.log every step you develop a function, to see what it actually does; here's a loop inside a loop visualization
function findloopduplicate(arr){
    for (var i=0; i<arr.length; i++){
        for (var j=0; j<arr.length; j++){
        console.log ("Arr[i] is: " + arr[i] + " Arr[j] is: " + arr[j]);
        }
    }
}
As you see, arr[i] will stay as the first item, while arr[j] will loop through the array;
Javier Pons
@JavierPons
@Marianissimus thanks!
CamperBot
@camperbot
javierpons sends brownie points to @marianissimus :sparkles: :thumbsup: :sparkles:
:cookie: 455 | @marianissimus |http://www.freecodecamp.org/marianissimus
Javier Pons
@JavierPons
@Marianissimus How can I test in the Google console? findloopduplicate ( [2,2,3,4,5,,8,7,5]);?
Marianissimus
@Marianissimus
ctrl+c the function, open the console (ctrl+shift+j), paste the function (ctrl+v)
Javier Pons
@JavierPons
@Marianissimus yes I did like that but it gives me undefined
solve
Marianissimus
@Marianissimus
you have some typos in the array. also, write the argument immediately after the function name
findloopduplicate([2,2,3,4,5,8,7,5]);
Muhammed Hafiz
@zifahm

https://beta.freecodecamp.org/en/challenges/react/give-sibling-elements-a-unique-key-attribute

const renderFrameworks = frontEndFrameworks.map(function (value,index){
    <li key={index}>{value}</li>
  }

nothing gets rendered?

Frameworks() needs to map the array to an unordered list, much like in the last challenge. Finish writing the map callback to return an li element for each framework in the frontEndFrameworks array. This time, make sure to give each li a key attribute, set to a unique value.
what i have done is not correct?
geoffrymichael
@geoffrymichael
image.png
whoops, i dont know how this works. Anyway, I was trying to get rid of white space in between my bootstrap navbar and an h1 element placed directly below it.
i named an id to the h1 to hopefully override any bootstrap specificity and then tried to run through anything i could think of to get rid of the top spacing that seems to be the culprit for the h1
image.png
Stephen James
@sjames1958gm
@zifahm You need to return something inside the callback function
@zifahm
return <li key={index}>{value}</li>
Muhammed Hafiz
@zifahm
@sjames1958gm thanks, yeah i realised it later lol
CamperBot
@camperbot
zifahm sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8861 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
Stephen James
@sjames1958gm
@zifahm great, I make that mistake alot
Muhammed Hafiz
@zifahm
@sjames1958gm i am stuck here currently
https://beta.freecodecamp.org/en/challenges/react-and-redux/extract-state-logic-to-redux
const ADD = 'ADD';

const addMessage = (data) => {
  return {
    type:"ADD"
    message:data
  }
}


const messageReducer = (state=[],action) => {
  switch(action.type) {
    case 'ADD':
      return Object.assign({},state,{
        message:action.message
      })
      default:
      return state
  }
}

var store = Redux.createStore(messageReducer)
console says unexpected token near message in action creator
Stephen James
@sjames1958gm
@zifahm Missing comma after "ADD" (also you are supposed to use the variable ADD in place of the string)
Muhammed Hafiz
@zifahm
@sjames1958gm lol
half an hour on this
ahh now the immutable error !!
Dispatching addMessage against the store should immutably add a new message to the array of messages held in state.
wouldn't my reducer work?
Stephen James
@sjames1958gm
@zifahm array of messages
Muhammed Hafiz
@zifahm
got it!
Stephen James
@sjames1958gm
@zifahm :+1:
Muhammed Hafiz
@zifahm
return [...state,array.message]
so the thing i did before what did happen there in the state ? @sjames1958gm
Stephen James
@sjames1958gm
@zifahm well I am thinking you converted state from an array to an object containing an array called state with a extra value called message