No console . log

For some unknown reason for like the 5th time, my console.log() wont work and Im not sure why. Even trying cntrl shift J, it wont show up there either, not sure why nothing shows up there. It seems to be working perfectly fine, but I add one tiny little code and then it wont work until I get to the next challenge, and even then it might work it might not.

  **Your code so far**

function whatIsInAName(collection, source) {
const arr = [];
// Only change code below this line
let keys = Object.keys(source);

for (let i = 0;i < collection.length;i++){
if(collection[i].hasOwnProperty(keys) && collection[i].hasOwnProperty(collection[keys])){
  arr.push(collection[i])
  return console.log(arr)
  }
}
// Only change code above this line
return arr;
}

whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:99.0) Gecko/20100101 Firefox/99.0

Challenge: Wherefore art thou

Link to the challenge:

Hello there @alexdlcruz89 I’m not quite sure how to help. Do you have an issue with the console.log() function in your browser or with your code? Sometimes addBlockers interfere with tests so I’d advise turning that off while you’re busy on the FCC curriculum.

So console.log() after adding arr to the parameter, stopped logging and wouldn’t log anything no matter where I put it in the code. I have never been able to see anything logged to the browser console since first learning how to on FCC. I do have an adblocker, so it might just be that.

if you remove the return from in front of the console log statement?

For me, this did nothing. It’s like console.log broke and couldnt fix itself. Its happened one other time last friday I think, I was typing code and instead of a return I just simply put console.log(random parameter), I added a else statement after the original if statment as one does, after adding a return there the console.log broke and I couldnt use it for that challenge either.

Probably not a great example, but the console.log was setup like that and after adding that else, console.log no longer worked no matter what I put in, or where I put it. It was super weird and a little frustrating.

Example code(from memory):

function(blah blah){

let count = 0;

for(let blah blah blah){

if(this happens){

count++;

console.log(count)

}else {

return "the flask or you'll be cursed forever"
}
}
}
function brokenConsole(number){
    if(number === 0){
        console.log('you will only see this if number is 0')
    }
    console.log('you will always see this console.log()')
}

console.log(brokenConsole(1))

If there is a condition that is not met in your if statement it will not run that code, even if its a console.log(). In your if with the console.log you are always getting a false so it is not running.

1 Like

That actually sounds like it would be exactly my problem, I will be thoughtful of that going forward. I was expecting something to always be there without considering if the condition was fulfilled or not.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.