These are chat archives for FreeCodeCamp/HelpJavaScript

9th
May 2017
Mike
@MikeJSchorah
May 09 2017 00:02
Has anyone done interviews?
the0ffh
@the0ffh
May 09 2017 00:03
Hello!
Could someone help me with quicksort algorithm?
EK Azubuike
@ekazubuike
May 09 2017 00:16
Hey, jQuery question! So, for the other intermediate projects, I've been using the $.getJSON() method to query API's. I'm trying to figure out the Twitch.tv project with the $.ajax() method. My question is this: is the success: function (data) {...} part of the $.ajax() method the same as the function(json){...} part of the $.getJSON(url, function (json) {...} method?
Coy Sanders
@coymeetsworld
May 09 2017 00:16
getJSON is ajax, just a shorthand version of it
and yes they are similar
Vamp
@the-vampiire
May 09 2017 00:18
@ekazubuike you can read my writeup about the project if you want
https://medium.com/@vampiire/free-code-camp-multitwitch-project-556446003787
EK Azubuike
@ekazubuike
May 09 2017 00:18
thanks @coymeetsworld
CamperBot
@camperbot
May 09 2017 00:18
ekazubuike sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 2544 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
EK Azubuike
@ekazubuike
May 09 2017 00:18
thanks @the-vampiire
CamperBot
@camperbot
May 09 2017 00:18
ekazubuike sends brownie points to @the-vampiire :sparkles: :thumbsup: :sparkles:
:cookie: 371 | @the-vampiire |http://www.freecodecamp.com/the-vampiire
Vamp
@the-vampiire
May 09 2017 00:18
went into detail on the subject. same path went from using .get to having to learn .ajax. explained it all and more in there
Mike
@MikeJSchorah
May 09 2017 00:22
Does anyone know how difficult it is for a code monkey to get a job?
Jianhao Tan
@jaanhio
May 09 2017 00:22

hi all, may i know why does this success function return “uncaught type error: cannot read property ‘0’ of undefined

success: function(data){
    console.log(data.query.search[0].title);
    console.log(data.query.search[0].wordcount);
    console.log(data.query.search[3].title);
    console.log(data.query.search[3].wordcount);
    console.log(data.query.search);
    $('.loader').fadeOut(400);
    $('.article').fadeOut(400);
    $(data.query.search).each(function(y){
      $('#searchResults').append('<div class="article">' + '<h4 class="title">' + data.query.search[y].title +'</h4>'+ '<br/>'+'<a href="https://en.wikipedia.org/?curid='+ data.query.search[y].size +'" class="randomLink">'+ data.query.random[y].title+'</a>'+ '</div>');
      //$('#searchResults').append('<div class="article">' + '<p>'+ data.query.random[x].id + '</p>'+'</div>');
    });
  },

url is https://en.wikipedia.org/w/api.php?action=query&list=search&srwhat=text&format=json&srsearch=iron%20man

the console.logs return correct results
so i have no idea why i will be getting error when using the .each method on it
Vamp
@the-vampiire
May 09 2017 00:25
what does data.query.search look like?
Csaba Balogh
@JasonCorp84
May 09 2017 00:26
Hello everyone
Mike
@MikeJSchorah
May 09 2017 00:26
Hi Csaba
Csaba Balogh
@JasonCorp84
May 09 2017 00:27
"Cannot read property '9' of undefined
does anyone know what is that mean ?
Vamp
@the-vampiire
May 09 2017 00:27
not without the code
@jaanhio you need to tell us what data.query.search looks like (screenshot of the cosole log) and also why are you running an each method on it with a parameter y but passing an x into random? where is x defined?
Csaba Balogh
@JasonCorp84
May 09 2017 00:28
image.png
Vamp
@the-vampiire
May 09 2017 00:29
next time its easier if you paste the code in here
using this format
```js
new line
paste code here
new line
```
Csaba Balogh
@JasonCorp84
May 09 2017 00:30
ok I will
Vamp
@the-vampiire
May 09 2017 00:30
but looking at it it appears youre initializing var i as arr.length
Csaba Balogh
@JasonCorp84
May 09 2017 00:30
yep that is pointing out of the arrays index
even if I change that to -1 I got a different number
Vamp
@the-vampiire
May 09 2017 00:31
I think that should be arr.length -1
arr.length is the length of the array, but arrays are 0 indexed so length is going to be 1 higher than the last index
as you can see your str has 9 “words” which become 9 “elements” when they are split into the array
HeebieGeeBee
@HeebieGeeBee
May 09 2017 00:32
@JasonCorp84 first spell length correctly everywhere
Vamp
@the-vampiire
May 09 2017 00:33
thats why it is saying it cant read property 9 of undefined. the final word is at index 8 (length - 1) not index 9 (length)
Csaba Balogh
@JasonCorp84
May 09 2017 00:33
arr[i].legth ? :D
lol
HeebieGeeBee
@HeebieGeeBee
May 09 2017 00:33
and and its arr[i].length
Vamp
@the-vampiire
May 09 2017 00:33
ya that would help as well
HeebieGeeBee
@HeebieGeeBee
May 09 2017 00:34
and then might help if you initialize big with a value too
Vamp
@the-vampiire
May 09 2017 00:34
right
Csaba Balogh
@JasonCorp84
May 09 2017 00:36

function findLongestWord(str) {
var arr = str.split(' ');
var big;

for (var i = arr.length -1; i >= 0; i--){
big = arr[i].length;
if (big > arr[i].length){
big = arr[i].length;
}

}
return big;
}

findLongestWord("The quick brown fox jumped over the lazy dog");

something like this ?
Vamp
@the-vampiire
May 09 2017 00:36
so recap:
arrays are 0 indexed, if you are counting backwards from the last index this will be at arr.length -1
if you want to compare “big” to a value you need to give it an initial value (0 works)
if you want to compare the length of one of the “words” [elements] in your split array you have to use arr[i].length where arr[i] is the element at index i of your array
HeebieGeeBee
@HeebieGeeBee
May 09 2017 00:36
@JasonCorp84 big < arr[i].length
Kate
@thecodingblues
May 09 2017 00:36
Hi, folks. I'm struggling with "Stand in Line." I've got all but the second requirement ("nextInLine([2], 1) should return 2") accomplished. I'll paste my code below -- what am I missing?

function nextInLine(arr, item) {
arr.push();
arr.shift();

return arr.push(item);
}

// Test Setup
var arr = [1,2,3,4,5];

// Display Code
console.log("Before: " + JSON.stringify(arr));
console.log(nextInLine(arr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(arr));

Vamp
@the-vampiire
May 09 2017 00:37
@thecodingblues first tell me what does .push() and .shift() do?
Csaba Balogh
@JasonCorp84
May 09 2017 00:38
@HeebieGeeBee thank you
CamperBot
@camperbot
May 09 2017 00:38
jasoncorp84 sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1601 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
Vamp
@the-vampiire
May 09 2017 00:38
and what do they return
Csaba Balogh
@JasonCorp84
May 09 2017 00:38
@the-vampiire thank you
CamperBot
@camperbot
May 09 2017 00:38
jasoncorp84 sends brownie points to @the-vampiire :sparkles: :thumbsup: :sparkles:
:cookie: 372 | @the-vampiire |http://www.freecodecamp.com/the-vampiire
Csaba Balogh
@JasonCorp84
May 09 2017 00:40
image.png
Vamp
@the-vampiire
May 09 2017 00:40
nice
good job dude
Keon Samuel
@keonsam
May 09 2017 00:41
you are one step away from being one step away from being one step away.
Csaba Balogh
@JasonCorp84
May 09 2017 00:41
well thanks for you guys! FCC <3
Keon Samuel
@keonsam
May 09 2017 00:42
do this @keonsam thanks.
CamperBot
@camperbot
May 09 2017 00:42
sorry keonsam, you can't send brownie points to yourself! :sparkles: :sparkles:
Kate
@thecodingblues
May 09 2017 00:42
@the-vampiire .push() puts an argument at the end of an array and returns the amended array; .shift() takes out the first element of an array and returns that value?
Vamp
@the-vampiire
May 09 2017 00:43
ya
so apply that knowledge to the problem
what do you want to put at the end of the array?
what do you want to do with the first element of the array after this?
Moisés Man
@moigithub
May 09 2017 00:44
push do NOT return an array @thecodingblues
Kate
@thecodingblues
May 09 2017 00:45
Thank you, @moigithub. I was a little fuzzy on that detail.
CamperBot
@camperbot
May 09 2017 00:45
thecodingblues sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3209 | @moigithub |http://www.freecodecamp.com/moigithub
Keon Samuel
@keonsam
May 09 2017 00:45
arr.push(item);
Kate
@thecodingblues
May 09 2017 00:45
So I want to push the item, and then shift the result of that first 'pushed' item?
Keon Samuel
@keonsam
May 09 2017 00:46
yeah
Vamp
@the-vampiire
May 09 2017 00:46
sorry @moigithub is right
Keon Samuel
@keonsam
May 09 2017 00:46
well
Vamp
@the-vampiire
May 09 2017 00:46
it returns the number of itmes in the array
the length of the array*
Kate
@thecodingblues
May 09 2017 00:46
Do I need to assign them as variables so that I can return the final result?
Keon Samuel
@keonsam
May 09 2017 00:46
no try return arr.shift()
Vamp
@the-vampiire
May 09 2017 00:47
arr.shift() returns the removed item

so if you put that in your return statement it will be evaluated as

return arr.shift() —> return first item

Kate
@thecodingblues
May 09 2017 00:49
Sorry, everyone. I'm still a little lost. Do I need to assign variables or not?
Vamp
@the-vampiire
May 09 2017 00:49
write your code
the way you just described first
and well evaluate from there
Kate
@thecodingblues
May 09 2017 00:51

function nextInLine(arr, item) {
arr.push(item);
arr.shift();

return arr.shift();
}

// Test Setup
var arr = [1,2,3,4,5];

// Display Code
console.log("Before: " + JSON.stringify(arr));
console.log(nextInLine(arr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(arr));

Not sure what to do with arr.shift();
Keon Samuel
@keonsam
May 09 2017 00:51
arr.push(item)
return arr.shift();
remove the other arr.shift();
Kate
@thecodingblues
May 09 2017 00:52
Oh god, was it that easy?
Thank you, @keonsam.
CamperBot
@camperbot
May 09 2017 00:52
thecodingblues sends brownie points to @keonsam :sparkles: :thumbsup: :sparkles:
:cookie: 362 | @keonsam |http://www.freecodecamp.com/keonsam
Kate
@thecodingblues
May 09 2017 00:53
I was overthinking it to the extreme.
And thank you, @the-vampiire, for walking me through my thinking.
CamperBot
@camperbot
May 09 2017 00:53
thecodingblues sends brownie points to @the-vampiire :sparkles: :thumbsup: :sparkles:
:cookie: 373 | @the-vampiire |http://www.freecodecamp.com/the-vampiire
Vamp
@the-vampiire
May 09 2017 00:53
@thecodingblues no problem, thats the best way to approach problems
speak out loud to yourself often youll see the holes in your logic
Kate
@thecodingblues
May 09 2017 00:54
Ha, great. :)
Vamp
@the-vampiire
May 09 2017 00:54
when you get to more advanced challenges try writing pseudocode before. meaning write the approach to the code in plain english before you even begin writing in JS
you can usually work out the kinks or deficiencies in your approach before getting caught up lost in your own code
in your pseudocode you migh say “after this do x” and you know x is possible but youre not quite sure how. so now once youve laid out the plan you can go research x and understand it THEn get to the code and it all falls into place (most of the time) lol
Kate
@thecodingblues
May 09 2017 00:58
Oh man, such good advice. Thank you!
I'll definitely try it and see how it goes. Otherwise, I'll return...!
(Hopefully that doesn't seem like a threat, lol. ;))
Vamp
@the-vampiire
May 09 2017 00:59
oh youl be back
lol
I love this chat. gotten a lot of help over the past month and a half, and I always give back on topics I’ve covered / understand. do the same as you make progress
Stephen James
@sjames1958gm
May 09 2017 01:06
@thecodingblues It's called rubber duck debugging - you have to explain your code to your rubber duck and in the process you find your errors.
dyon3334
@dyon3334
May 09 2017 01:08
hello :) how can i add my code in a viewer ?

what am i doing wrong: var location1 = 3;
var location2 = 4;
var location3 = 5;
var guess
var hits = 0;
var guesses = 0;
var isSunk = false;

while (isSunk == false) {
guess = prompt("Ready, aim, fire! (enter a number from 0-6):");
if (guess < 0 || guess > 6) {
alert("Please enter a valid cell number!");
} else {
guesses = guesses + 1;
if (guess == location1 || guess == location2 || guess == location3) {
hits = hits + 1;
if (hits == 3) {
isSunk = true;
alert("You sank my battleship!");
if (guess == location1 || guess == location2 || guess == location3) {
alert("you hit my ship");
}
}
}
}
var stats = "You took " + guesses + " guesses to sink the battleship, " +
"which means your shooting accuracy was " + (3/guesses);
alert(stats);

Corey Pennington
@JuiceyDuecy
May 09 2017 01:12
@dyon3334 do you mean markdown? as in the var abc = 'abc'?
dyon3334
@dyon3334
May 09 2017 01:13
@JuiceyDuecy i added the if statement with the string "you hit my ship"
after that it didnt work anymore
will
@uhohtrouble
May 09 2017 01:16
Hi
in an object,
var testObj = {
Gabe Rotberg
@grotberg
May 09 2017 01:17
@dyon3334 It kinda looks like you're calling the "you hit my ship" check inside the "you sank my ship" check. so you'll always see both of them when the ship sinks but neither otherwise?
will
@uhohtrouble
May 09 2017 01:17

1: "eg",
2: "ge",
3: "he", };

how would i call the number?

Gabe Rotberg
@grotberg
May 09 2017 01:18
@uhohtrouble testObj.1 or testObj[1] or testObj["1"]
will
@uhohtrouble
May 09 2017 01:18
the actual number, not the value
as a position in the object
dyon3334
@dyon3334
May 09 2017 01:19
@grotberg thanks i cant understand can you explain more
CamperBot
@camperbot
May 09 2017 01:19
dyon3334 sends brownie points to @grotberg :sparkles: :thumbsup: :sparkles:
:cookie: 343 | @grotberg |http://www.freecodecamp.com/grotberg
dyon3334
@dyon3334
May 09 2017 01:19
or make a example for me how it should be
Corey Pennington
@JuiceyDuecy
May 09 2017 01:19
@uhohtrouble two ways to call it
Gabe Rotberg
@grotberg
May 09 2017 01:19
@uhohtrouble hm, the keys of an object don't really have positions per se. I think there's a Object.keys() function you can get to list them all, though - something along those lines, although the syntax escapes me
FlashHero
@FlashHero
May 09 2017 01:20

function uniteUnique(arr) {
  var result=[];
  var args = Array.prototype.slice.call(arguments);
  args=args.join().split();
 for(var i=0;i<args.length;i++){
    if(!result.includes(args[i])){
      result.push(args[i]);
    }
}
  return result;
}

uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1]);
I need help I don't know what's wrong
Corey Pennington
@JuiceyDuecy
May 09 2017 01:20
dot notation or bracket notation @uhohtrouble depends on what info you want
will
@uhohtrouble
May 09 2017 01:20
@grotberg ah okay, thank you
CamperBot
@camperbot
May 09 2017 01:20
:cookie: 344 | @grotberg |http://www.freecodecamp.com/grotberg
uhohtrouble sends brownie points to @grotberg :sparkles: :thumbsup: :sparkles:
will
@uhohtrouble
May 09 2017 01:20
@JuiceyDuecy currently using bracket
in the tut, it's introduced more variables than what I have to work with in the test, and I'm not allowed to edit the variables to add more
David Amanze
@GodKingShogun
May 09 2017 01:21
hello everyone
Gabe Rotberg
@grotberg
May 09 2017 01:21
@dyon3334 well, you have an if statement to see if (hits == 3). and then you set isSunk and you alert "You sank my battleship" and inside that if statement you have another (nested) ifstatement that asks if the hit location was 1, 2 or 3, send another alert (You hit my ship)
David Amanze
@GodKingShogun
May 09 2017 01:21
is this how you write self closing function
var fToC = ((temp) => {
      const d = 9/5;
      temp = temp-32;
      temp = temp/d;
      return temp;
    })();
Gabe Rotberg
@grotberg
May 09 2017 01:22
@dyon3334 so basically, to get to that inner most nested if statement, all the previous if statements also have to be true;

@dyon3334 lets say you have this code:

if (a is true) {
  doThingA();
  if (b is true) {
    doThingB();
  }
}

doThinkB will never happen unless both a & b are true, because it is nested inside both of those if statements

@dyon3334 if you wanted doThingB to happen without a being true, you need to rearrange the code:
if (a is true) {
  doThingA();
}
if (b is true) {
  doThingB();
}
In that example, they aren't nested, so the success of B doesn't rest on A as well
Joseph
@revisualize
May 09 2017 01:28
@GodKingShogun Your order of operations is incorrect
nsonhouse
@nsonhouse
May 09 2017 01:28
@JLuboff That did not work. Any other suggestions?
Stephen James
@sjames1958gm
May 09 2017 01:29
@GodKingShogun That is an IIFE - it is called immediately - you need to pass something in the () in the bottom
Joseph
@revisualize
May 09 2017 01:29
@GodKingShogun There is a very distinct order to convert f to c
Stephen James
@sjames1958gm
May 09 2017 01:30
@GodKingShogun fToC will be assigned a value (here NaN because temp is undefined)
will
@uhohtrouble
May 09 2017 01:32
is there any advantage to using bracket notation over dot or vice versa
pooranp
@pooranp
May 09 2017 01:32

You will need to use string operators to build a new string, result, using the provided variables: myNoun, myAdjective, myVerb, and myAdverb.

You will also need to use additional strings, which will not change, and must be in between all of the provided words. The output should be a complete sentence.

^can anybody explain to me what this means?
FlashHero
@FlashHero
May 09 2017 01:33
@revisualize can you help me ?
Gulsvi
@gulsvi
May 09 2017 01:33
@uhohtrouble dot notation is usually considered to be clearer and easier to read.
will
@uhohtrouble
May 09 2017 01:33
You need to combine the strings into one, as well as adding in some new strings @pooranp
@pooranp example, myNoun + " says Hello";
@SkyCoder01 thanks
CamperBot
@camperbot
May 09 2017 01:34
uhohtrouble sends brownie points to @skycoder01 :sparkles: :thumbsup: :sparkles:
:star2: 1326 | @skycoder01 |http://www.freecodecamp.com/skycoder01
pooranp
@pooranp
May 09 2017 01:35
@uhohtrouble okay, thanks!
CamperBot
@camperbot
May 09 2017 01:35
:cookie: 206 | @uhohtrouble |http://www.freecodecamp.com/uhohtrouble
pooranp sends brownie points to @uhohtrouble :sparkles: :thumbsup: :sparkles:
Gabe Rotberg
@grotberg
May 09 2017 01:36
@uhohtrouble dot notation is nicer when you can use it, but imagine the case where you need to access an object property, but which property it is is variable. in that case you have to use the bracket notation
pooranp
@pooranp
May 09 2017 01:42
wordBlanks("dog", "big", "ran", "quickly") should contain all of the passed in words separated by non-word characters (and any additional words in your madlib).
^can anyone explain what that rule means?
will
@uhohtrouble
May 09 2017 01:43
@grotberg thanks
CamperBot
@camperbot
May 09 2017 01:43
uhohtrouble sends brownie points to @grotberg :sparkles: :thumbsup: :sparkles:
:warning: uhohtrouble already gave grotberg points
Kingsley
@Kingwindie
May 09 2017 01:44
fellas can anyone help me with this code,i don't want the button to disappear after the user clicks it,also i don't want the whole paragraph to be missing after the second click https://codepen.io/kingwindie/pen/bWogbZ?editors=1010
Matt
@northern11
May 09 2017 01:44
@pooran you are supposed to create a string with words separated by non-word characters
will
@uhohtrouble
May 09 2017 01:44
@pooranp all the words that go in should be seperated by a character, the character cant be a word, so a space would work because its not a word
Gabe Rotberg
@grotberg
May 09 2017 01:47
@Kingwindie well, when you click your button, it says text3 = text1 + text2, then it sets text1 and text2 to empty
Matt
@northern11
May 09 2017 01:47
the goal is to create a sentence that has basically fill in the blanks that are filled with the provided variables
Gabe Rotberg
@grotberg
May 09 2017 01:47
@Kingwindie so the next time you click the button, text1 and text2 are both empty still, and text3 = empty + empty, and its empty too
@Kingwindie so, you might need to rethink the logic somehow to keep that from happening.
Kingsley
@Kingwindie
May 09 2017 01:51
@grotberg the tutorial i am watching sets it to where the button disappears after one click,which i don't want it that way,and i don't exactly know any other way to write the code
Gabe Rotberg
@grotberg
May 09 2017 01:52
@Kingwindie the button isn't disappearing for me in your code
@Kingwindie if you write it so the text is assigned back to the first text element (instead of the 3rd), clicking the button multiple times won't end up deleting the text;
Kingsley
@Kingwindie
May 09 2017 01:53
@grotberg @grotberg https://codepen.io/kingwindie/pen/bWogbZ?editors=1010 i think i sent the wrong code,look at this one
pooranp
@pooranp
May 09 2017 01:53
how do I enter spaces between words in a string?
Kingsley
@Kingwindie
May 09 2017 01:54
@pooranp just press the space bar
between the quotes
Kristopherlb
@Kristopherlb
May 09 2017 01:54

where the heck am I going wrong with this?

It doesnt iterate through the third value [5,6,7]

function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  for (var i = 0; i <= arr.length; i++){
    for (var j = 1; j <= arr[i].length; j++){
      product = product * j;
    }
}
  // Only change code above this line
  return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
@pooranp either 'string ' + 'string' or 'string' + ' ' + 'string'
There is a space after the word string and the end quote if you couldn't tell.
HeebieGeeBee
@HeebieGeeBee
May 09 2017 01:58
@Kristopherlb youre meant to be multiplying every element of all the arrays with the product variable
youre just multiplying it with the loop variable j
David Amanze
@GodKingShogun
May 09 2017 01:59
@revisualize if i am converting from f to c then i would subtract @sjames1958gm it was just an example. i have the variable declared in my code already
32 then divde by 9/5
HeebieGeeBee
@HeebieGeeBee
May 09 2017 01:59
@GodKingShogun yo
David Amanze
@GodKingShogun
May 09 2017 01:59
@HeebieGeeBee sup
HeebieGeeBee
@HeebieGeeBee
May 09 2017 02:00
not much
hows you?
David Amanze
@GodKingShogun
May 09 2017 02:01
creating my port
HeebieGeeBee
@HeebieGeeBee
May 09 2017 02:01
@Kristopherlb also dont use <= just < and make sure your loop variables all start from 0
@GodKingShogun port?
David Amanze
@GodKingShogun
May 09 2017 02:01
portfolio
ill link it when i am done :smile:
HeebieGeeBee
@HeebieGeeBee
May 09 2017 02:02
oh ok
Kristopherlb
@Kristopherlb
May 09 2017 02:05

@HeebieGeeBee shouldn't that be what its doing?

I tried just < and 0 earlier and it doesnt work.

I dont know why the way I have it doesnt multiply all the elements. As it is now I get 24, which to me looks like it is going through the first 2 elements but not the third.

HeebieGeeBee
@HeebieGeeBee
May 09 2017 02:05
@Kristopherlb no, youre not accessing the elements of the array
Kristopherlb
@Kristopherlb
May 09 2017 02:06
then what is it multiplying?
HeebieGeeBee
@HeebieGeeBee
May 09 2017 02:06
youre just using the value of the j variable
do you understand why we make loops with a variable like that?
its so we have a variable that we can use as value for an index
Kristopherlb
@Kristopherlb
May 09 2017 02:09
i get the loop, mostly. I dont know why it isnt taking the argument though.
Fabusuyi David Oluwasegun
@dav4thevid
May 09 2017 02:09
hey guys..have been batting with the Ceasars Cipher challenge......i guess dis code should work buh its not passing

function rot13(str) { // LBH QVQ VG!
  var arr = [];
  for (i = 0;i<arr.length;i++){
    if (str.charCodeAt(i)>= 65 && str.charCodeAt(i)<=77){
      arr.push(str.fromCharCode(str.charCodeAt(i)+13));
  }
  else if (str.charCodeAt(i)>=78 && str.charCodeAt(i)<=90){
    arr.push(str.fromCharCode(str.charCodeAt(i)-13));
  }
  else if (str.arr.charCode(i)<65){
    arr.push(str[i]);}
  }

document.write (arr.join(""));
}
// Change the inputs below to test
rot13("SERR PBQR PNZC");
pls any help
HeebieGeeBee
@HeebieGeeBee
May 09 2017 02:10
@Kristopherlb how would you access the 1 value in the array ? @Kristopherlb
@dav4thevid were you going to split the string into an array at all?
or at least use str for the loop
Fabusuyi David Oluwasegun
@dav4thevid
May 09 2017 02:13
@HeebieGeeBee nooo.....i dont wanna split it
HeebieGeeBee
@HeebieGeeBee
May 09 2017 02:13
and its String.fromCharCode..
also this is wrong str.arr.charCode(i)<65
@dav4thevid use str.length for your loop then
Fabusuyi David Oluwasegun
@dav4thevid
May 09 2017 02:14
oooooooooooooooo i seeeeeeeeeeeeeeeee @HeebieGeeBee
Kristopherlb
@Kristopherlb
May 09 2017 02:16
@HeebieGeeBee the 1 value from product or from the array?
HeebieGeeBee
@HeebieGeeBee
May 09 2017 02:16
from the array
FlashHero
@FlashHero
May 09 2017 02:16

function uniteUnique(arr) {
  var result=[];
  var args = Array.prototype.slice.call(arguments);
var array = JSON.parse("[" + args + "]");
 for(var i=0;i<array.length;i++){
    if(!result.includes(array[i])){
      result.push(array[i]);
    }
}
  return result;
}

uniteUnique([1, 3, 2], [1, [5]], [2, [4]]);
why is this not working
Mike
@MikeJSchorah
May 09 2017 02:17
Has anyone been job hunting?
HeebieGeeBee
@HeebieGeeBee
May 09 2017 02:17
what are you meant to be doing? @FlashHero
Joseph
@revisualize
May 09 2017 02:18
@MikeJSchorah Nope.
FlashHero
@FlashHero
May 09 2017 02:18
@HeebieGeeBee its supposed to return the whole nested array instead its only returning only the number, It works just for the numbers but for an nested array it doesn't work help please
@HeebieGeeBee Sorted Union challenge
Dovydas Stirpeika
@Giveback007
May 09 2017 02:20
hey there fellow campers
Mike
@MikeJSchorah
May 09 2017 02:20
How difficult is it to get a job if you are a code monkey?
Keon Samuel
@keonsam
May 09 2017 02:20
code monkey?
Fabusuyi David Oluwasegun
@dav4thevid
May 09 2017 02:20

function rot13(str) { // LBH QVQ VG!
  var arr = [];
  for (i = 0;i<str.length;i++){
    if (str.charCodeAt(i)>= 65 && str.charCodeAt(i)<=77){
      arr.push(String.fromCharCode(str.charCodeAt(i)+13));
  }
  else if (str.charCodeAt(i)>=78 && str.charCodeAt(i)<=90){
    arr.push(String.fromCharCode(str.charCodeAt(i)-13));
  }
  else if (str.arr.charCode(i)<65){
    arr.push(str[i]);}
  }

document.write (arr.join(""));
}
// Change the inputs below to test
rot13("SERR PBQR PNZC");
@HeebieGeeBee its still not passing
Dovydas Stirpeika
@Giveback007
May 09 2017 02:21
regarding the twitch api project, if I am using the workaround do I still require to register for an ID?
https://wind-bow.glitch.me/
HeebieGeeBee
@HeebieGeeBee
May 09 2017 02:21
@dav4thevid your last else if condition is wrong
Kristopherlb
@Kristopherlb
May 09 2017 02:21
@HeebieGeeBee Thats what im not getting. Im not sure what i need to do to get j to hold the value of the array position.
Mike
@MikeJSchorah
May 09 2017 02:21
@keonsam Code monkey. One who copies and pastes code. Everyone supposedly does it except for the geniuses.https://softwareengineering.stackexchange.com/questions/36978/do-most-programmers-copy-and-paste-code
My question is: How the hell do you pass a technical exam to get the job?
HeebieGeeBee
@HeebieGeeBee
May 09 2017 02:22
@revisualize you got anything for @Kristopherlb abotu accessing elements in arrays?
Fabusuyi David Oluwasegun
@dav4thevid
May 09 2017 02:23

function rot13(str) { // LBH QVQ VG!
  var arr = [];
  for (i = 0;i<str.length;i++){
    if (str.charCodeAt(i)>= 65 && str.charCodeAt(i)<=77){
      arr.push(String.fromCharCode(str.charCodeAt(i)+13));
  }
  else if (str.charCodeAt(i)>=78 && str.charCodeAt(i)<=90){
    arr.push(String.fromCharCode(str.charCodeAt(i)-13));
  }
  else if (str.charCodeAt(i)<65){
    arr.push(str[i]);}
  }

document.write (arr.join(""));
}
// Change the inputs below to test
rot13("SERR PBQR PNZC");
Fabusuyi David Oluwasegun
@dav4thevid
May 09 2017 02:24
have corrected it....buh its still not passing
Joseph
@revisualize
May 09 2017 02:24
@Kristopherlb I do.
Stephen James
@sjames1958gm
May 09 2017 02:24
@dav4thevid why are you not returning the joined array?
Joseph
@revisualize
May 09 2017 02:24
@HeebieGeeBee Sorry ... I do.
Dovydas Stirpeika
@Giveback007
May 09 2017 02:24
@XenoCoding tnx i'll look in to it.
CamperBot
@camperbot
May 09 2017 02:24
giveback007 sends brownie points to @xenocoding :sparkles: :thumbsup: :sparkles:
:cookie: 297 | @xenocoding |http://www.freecodecamp.com/xenocoding
Claudio Restifo
@Marmiz
May 09 2017 02:24

@MikeJSchorah

How the hell do you pass a technical exam to get the job

Of course you need to know at least a bit of what you're talking about... but generally speaking whiteboard interview are designed more to see how you tackle a problem than just merely solve one.

Joseph
@revisualize
May 09 2017 02:25
@Kristopherlb Hey.
Stephen James
@sjames1958gm
May 09 2017 02:25
@dav4thevid Your final else if should be a simple else
Mike
@MikeJSchorah
May 09 2017 02:25
@Marmiz Are you working in development?
Benjamin
@XenoCoding
May 09 2017 02:25
@Giveback007 ?
Kristopherlb
@Kristopherlb
May 09 2017 02:25
@revisualize Hello. Thanks @HeebieGeeBee
CamperBot
@camperbot
May 09 2017 02:25
kristopherlb sends brownie points to @revisualize and @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 3916 | @revisualize |http://www.freecodecamp.com/revisualize
:star2: 1602 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
Claudio Restifo
@Marmiz
May 09 2017 02:25
@MikeJSchorah :+1:
Joseph
@revisualize
May 09 2017 02:25
@Kristopherlb Can we side step your lesson for a second?
Kristopherlb
@Kristopherlb
May 09 2017 02:25
of course
Keon Samuel
@keonsam
May 09 2017 02:25
@MikeJSchorah isn't that plagiarism
Joseph
@revisualize
May 09 2017 02:26
@Kristopherlb I'm going to ask a few simple-ish questions.
HeebieGeeBee
@HeebieGeeBee
May 09 2017 02:26
@FlashHero sorry so are you trying to get all the numbers into one array?
Dovydas Stirpeika
@Giveback007
May 09 2017 02:26
@XenoCoding were you not giving the link in reference to my question?
Joseph
@revisualize
May 09 2017 02:26
@Kristopherlb First..
var arr = ["a", "b", "c", "d", "e"];
How do you access "d"?
Benjamin
@XenoCoding
May 09 2017 02:26
@Giveback007 No, I had a question of my own lol. I can answer your question though.
Mike
@MikeJSchorah
May 09 2017 02:27
@Marmiz Is that a yes?
dyon3334
@dyon3334
May 09 2017 02:27
can someone tell me what im doing wrong i dont get" missed my ship "while (isSunk === false) {
guess = prompt("Ready, aim, fire! (enter a number from 0-6):");
if (guess < 0 || guess > 6) {
alert("Please enter a valid cell number!");
} else {
guesses = guesses + 1;
if (guess == location1 || guess == location2 || guess == location3) {
hits = hits + 1;
if (guess == location1 || guess == location2 || guess == location3)
alert("you hit my ship");
else
alert("you missed my ship");
if (hits == 3) {
isSunk = true;
alert("You sank my battleship!");
Mike
@MikeJSchorah
May 09 2017 02:27
@keonsam It depends
Benjamin
@XenoCoding
May 09 2017 02:27
@Giveback007 For channel information: https://wind-bow.glitch.me/twitch-api/channels/ + channel name
Claudio Restifo
@Marmiz
May 09 2017 02:27
@MikeJSchorah yes :) (sorry thought it was clear)
Benjamin
@XenoCoding
May 09 2017 02:27
For streaming information: https://wind-bow.glitch.me/twitch-api/streams/ + channel name
Mike
@MikeJSchorah
May 09 2017 02:28
@Marmiz Thought that was what you meant. Haha. I've applied to 500 jobs... still nothing :(
Dovydas Stirpeika
@Giveback007
May 09 2017 02:28
@XenoCoding do you still need to get an ID to use the wtich API when you are using the workaround? (is the ID like a key?)
Fabusuyi David Oluwasegun
@dav4thevid
May 09 2017 02:28

@sjames1958gm ```

function rot13(str) { // LBH QVQ VG!
var arr = [];
for (i = 0;i<str.length;i++){ if (str.charCodeAt(i)>= 65 && str.charCodeAt(i)<=77){
arr.push(String.fromCharCode(str.charCodeAt(i)+13));
}
else if (str.charCodeAt(i)>=78 && str.charCodeAt(i)<=90){
arr.push(String.fromCharCode(str.charCodeAt(i)-13));
}
else (str.charCodeAt(i)<65){
return arr.push(str[i]);}
}

document.write (arr.join(""));
}
// Change the inputs below to test
rot13("SERR PBQR PNZC");

Keon Samuel
@keonsam
May 09 2017 02:28
hell 500
where are you from?
Fabusuyi David Oluwasegun
@dav4thevid
May 09 2017 02:28

function rot13(str) { // LBH QVQ VG!
  var arr = [];
  for (i = 0;i<str.length;i++){
    if (str.charCodeAt(i)>= 65 && str.charCodeAt(i)<=77){
      arr.push(String.fromCharCode(str.charCodeAt(i)+13));
  }
  else if (str.charCodeAt(i)>=78 && str.charCodeAt(i)<=90){
    arr.push(String.fromCharCode(str.charCodeAt(i)-13));
  }
  else  (str.charCodeAt(i)<65){
     return arr.push(str[i]);}
  }

document.write (arr.join(""));
}
// Change the inputs below to test
rot13("SERR PBQR PNZC");
Benjamin
@XenoCoding
May 09 2017 02:28
@Giveback007 No, you do not need to register for an ID. Just use the link.
Keon Samuel
@keonsam
May 09 2017 02:28
@MikeJSchorah
Joseph
@revisualize
May 09 2017 02:29
@MikeJSchorah What's your portfolio site?
Stephen James
@sjames1958gm
May 09 2017 02:29
@dav4thevid Just else not else with any condition else {
You are still not returning.
@dav4thevid return arr.join("");
Dovydas Stirpeika
@Giveback007
May 09 2017 02:29
ok cool, so everything will work the same with this work around, but it alows me to avoid using a key
Benjamin
@XenoCoding
May 09 2017 02:29
@Giveback007 yep
Stephen James
@sjames1958gm
May 09 2017 02:29
@dav4thevid Don't return inside your else either
Dovydas Stirpeika
@Giveback007
May 09 2017 02:29
@XenoCoding thank you
CamperBot
@camperbot
May 09 2017 02:29
giveback007 sends brownie points to @xenocoding :sparkles: :thumbsup: :sparkles:
:warning: giveback007 already gave xenocoding points
Mike
@MikeJSchorah
May 09 2017 02:29
@keonsamuel Maryland
Jason Luboff
@JLuboff
May 09 2017 02:29
I need to update my portfolio page...don't think I've added any of my advanced projects heh
Benjamin
@XenoCoding
May 09 2017 02:30
@Giveback007 np
Mike
@MikeJSchorah
May 09 2017 02:30
Stephen James
@sjames1958gm
May 09 2017 02:30
@dav4thevid
  else  {
     arr.push(str[i]);}
  }

return arr.join("");
Dovydas Stirpeika
@Giveback007
May 09 2017 02:30
if employers need coders so bad, why do I hear that it is hard to get a job? It seems like a mixed message from the market
Joseph
@revisualize
May 09 2017 02:30
@MikeJSchorah Well, that's part of your problem.
@MikeJSchorah Your portfolio site should be your own .com
Claudio Restifo
@Marmiz
May 09 2017 02:31
@MikeJSchorah my best advice is to build something really useful to stand out in your portfolio.
Think about a need that you have in your daily life and try to solve it.
Joseph
@revisualize
May 09 2017 02:31
@MikeJSchorah Does that mean that you have to buy web hosting ... Nope. You can host the page on Github just like you're doing.
Kristopherlb
@Kristopherlb
May 09 2017 02:31
console.log(arr[3]); @revisualize ?
Joseph
@revisualize
May 09 2017 02:32
@Kristopherlb Where did you get console.log() from? I didn't ask you how to log something to the console.
@Kristopherlb Not trying to be rude. Just trying to be direct.
TJ-strange
@TJ-strange
May 09 2017 02:32
hello
dyon3334
@dyon3334
May 09 2017 02:32
while (isSunk === false) {
guess = prompt("Ready, aim, fire! (enter a number from 0-6):");
if (guess < 0 || guess > 6) {
alert("Please enter a valid cell number!");
} else {
guesses = guesses + 1;
if (guess == location1 || guess == location2 || guess == location3) {
hits = hits + 1;
if (guess == location1 || guess == location2 || guess == location3)
alert("you hit my ship");
else
alert("you missed my ship");
if (hits == 3) {
isSunk = true;
alert("You sank my battleship!");
Joseph
@revisualize
May 09 2017 02:32
@Kristopherlb Simple questions .. Simple answers. .. Don't over think it.. You'll stress yourself out.
dyon3334
@dyon3334
May 09 2017 02:33
can someone telle me wwhat im doing wrong
Mike
@MikeJSchorah
May 09 2017 02:33
@Giveback007 Employers do need coders so bad. But, as I have found out, they need someone with EXPERIENCE. When I was in college, I heard the same thing about the field. My phone has been ringing off the hook, but when they find out that I don't have real world experience, the conversation goes dead
Dovydas Stirpeika
@Giveback007
May 09 2017 02:33
@dyon3334 everything!
Joseph
@revisualize
May 09 2017 02:33
@Kristopherlb Okay. So var arr = ["a", "b", "c", "d", "e"]; How do you access "d" is arr[3].
Kristopherlb
@Kristopherlb
May 09 2017 02:33
return arr[3]?
Joseph
@revisualize
May 09 2017 02:33
@Kristopherlb Next question.
Chris Jimenez
@cjimenez113
May 09 2017 02:33
I need some help with this problem wordBlanks("","","","") should return a string.
wordBlanks("dog", "big", "ran", "quickly") should contain all of the passed in words separated by non-word characters (and any additional words in your madlib).
wordBlanks("cat", "little", "hit", "slowly") should contain all of the passed in words separated by non-word characters (and any additional words in your madlib).

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line

// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");

Dovydas Stirpeika
@Giveback007
May 09 2017 02:34
@dyon3334 jk these smart peaople will help you out
Mike
@MikeJSchorah
May 09 2017 02:34
@Marmiz I've seen people with less "experience" than me who have gotten jobs. I think my issue is that I don't have any knowledge of the back-end. Right now, I'm taking a course on Udemy called "The Complete Web Developer Bootcamp." It shows how to do back-end work.
Kristopherlb
@Kristopherlb
May 09 2017 02:34
@revisualize simple enough.
Joseph
@revisualize
May 09 2017 02:34
@Kristopherlb var arr = [ [ "a" , "b" ] , [ "c" , "d" ] , [ "e" ] ]; ... How do you access "d" now?
Dovydas Stirpeika
@Giveback007
May 09 2017 02:35
@MikeJSchorah you are confident that back end will solve your problem?
Kristopherlb
@Kristopherlb
May 09 2017 02:35
arr[1[1]
Vikram
@vikramnr
May 09 2017 02:35

function largestOfFour(arr) {
var resultArr=[0,0,0,0];
for(var i=0;i<arr.length;i++){
var max = arr[i].reduce(function(a, b) {
resultArr[i]=max;
return Math.max(a, b);

});

}

return resultArr;
}

@revisualize can you help me out.. first value is returning null all other are fine

Joseph
@revisualize
May 09 2017 02:35
@Kristopherlb arr[1][1]
@Kristopherlb Right?
Chris Jimenez
@cjimenez113
May 09 2017 02:36
could use some help here please
Kristopherlb
@Kristopherlb
May 09 2017 02:36
@revisualize I thought those nested as well. But i was obviously wrong.
Dovydas Stirpeika
@Giveback007
May 09 2017 02:36
man I'm mesing up today
Vikram
@vikramnr
May 09 2017 02:37
@revisualize I got it
Joseph
@revisualize
May 09 2017 02:37
@Kristopherlb So, If I asked.. How do you access "b" in that same array?
@Kristopherlb Or if I asked how do you access "e"
Kristopherlb
@Kristopherlb
May 09 2017 02:37
arr[1][1]
Claudio Restifo
@Marmiz
May 09 2017 02:37

@MikeJSchorah You don't need to know back-end if you want to focus on front-end.
(of course the more you know the better... but still.)

If I may be a little critic you present yourself as front-end and yet there's no evidence of any project made with one of the latest front end frameworks -> React - Angular - Vue.
If you want to be appealing you need to know a bit at least about latest technology.

If I had to start a new project (and we are about to do it now in my office) guess what we'll use as front-end framework?
The answer is not J-Query :)

Mike
@MikeJSchorah
May 09 2017 02:37
@Giveback007 I think what will solve my problem is not giving up hope. All it takes is just one. It takes just one person to give you a chance. I might have to relocate 1-2 hours away, but if it's for something a tad better than WordPress, I sure as hell will do it to get at least a year or 2 of experience. And I live near big cities, so I could not image how difficult it is for someone living in a rural area
Joseph
@revisualize
May 09 2017 02:37
@Kristopherlb arr[1][1] that's "d"
@Kristopherlb What about "b" and "e"?
Kristopherlb
@Kristopherlb
May 09 2017 02:38
haha jesus. arr[0][1] e is arr[2][0]
Joseph
@revisualize
May 09 2017 02:38
@Kristopherlb Great.
Dovydas Stirpeika
@Giveback007
May 09 2017 02:39
@MikeJSchorah have you thought about doing some cheap freelance work just to have "real world experience"?
Claudio Restifo
@Marmiz
May 09 2017 02:39
Anyway FCC has a coding-job gitter channel where you can ask for help/ support / feedback and all that stuff, maybe can help you out?
https://gitter.im/FreeCodeCamp/CodingJobs
best of luck to you! And don't give up
Chris Jimenez
@cjimenez113
May 09 2017 02:39
Hello who here can give me a hand with this question?
Dovydas Stirpeika
@Giveback007
May 09 2017 02:39
@MikeJSchorah I was thinking of doing that after I finsih my front end
Joseph
@revisualize
May 09 2017 02:39
@Kristopherlb Are you starting to see a trend here with nested array elements?
Fabusuyi David Oluwasegun
@dav4thevid
May 09 2017 02:40
@sjames1958gm thanks man....finally it worked
CamperBot
@camperbot
May 09 2017 02:40
dav4thevid sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7193 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Mike
@MikeJSchorah
May 09 2017 02:40
@Marmiz You think so? You think the answer is Angular and React? Good point. I thought about that. I guess I'm being pulled in 2 directions. Some people say learn "back-end" some people say learn "Angular". All I know that it is pretty damn time consuming.
Kristopherlb
@Kristopherlb
May 09 2017 02:40
yes. @revisualize
Stephen James
@sjames1958gm
May 09 2017 02:40
@dav4thevid :checkered_flag:
@cjimenez113 I guess it depends on the question.
Joseph
@revisualize
May 09 2017 02:40

@Kristopherlb Like if I showed you this:

var myArray = [ [1,2,3] , [4,5,6] , [7,8,9] ];
myArray[0] is [1,2,3]
myArray[0][0] is 1
myArray[0][1] is 2
myArray[1] is [4,5,6]
myArray[1][1] is 5
myArray[2] is [7,8,9]
myArray[2][0] is 7

Chris Jimenez
@cjimenez113
May 09 2017 02:41
wordBlanks("","","","") should return a string.
wordBlanks("dog", "big", "ran", "quickly") should contain all of the passed in words separated by non-word characters (and any additional words in your madlib).
wordBlanks("cat", "little", "hit", "slowly") should contain all of the passed in words separated by non-word characters (and any additional words in your madlib).

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line

// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");

Mike
@MikeJSchorah
May 09 2017 02:41
@Giveback007 No, that would be worse IMO. I see some people that do that, but most freelance work seems to be in WordPress. Sure, I understand that it could teach me how to deal with clients, but I just don't want to end up in the black hole of WordPress work.
Dovydas Stirpeika
@Giveback007
May 09 2017 02:41
@MikeJSchorah not as time consuming as 500 applications with no results
Joseph
@revisualize
May 09 2017 02:41

@cjimenez113 Gist by revisualize / FreeCodeCamp - Word_Blanks.js
The function declaration was set up as... function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) giving the function name as wordBlanks and with four parameter of myNoun, myAdjective, myVerb and myAdverb.
There is more that I could go into (if you want I can) but, I'll sum it up with:
Parameters are treated like variables that represent the values that get passed into your function from the function call (arguments).

Here's an example of this:

function hello(fName, uName) {
     return "Hello " + fName + " " + uName + ", How is your day?";
}
hello("Joseph", "@revisualize"); // "Hello Joseph @revisualize, How is your day?"
hello("Bella", "@bellaknoti"); // "Hello Bella @bellaknoti, How is your day?"
hello("Andy", "@dirn"); // "Hello Andy @dirn, How is your day?"

You can use the fName and uName parameters just like a variable inside of your function.

Stephen James
@sjames1958gm
May 09 2017 02:41
@cjimenez113 The function provided has 4 parameters - myNoun, myAdjective, myVerb, myAdverb
the will contain the words to be combined into a sentence
Joseph
@revisualize
May 09 2017 02:42
@Kristopherlb So, with your challenge. There's a reason I'm bringing all of this up.
Dovydas Stirpeika
@Giveback007
May 09 2017 02:42
@MikeJSchorah why is wordpress so bad, it's not like they are going to trap you
Joseph
@revisualize
May 09 2017 02:42
@MikeJSchorah Can you get yourself a .com?
@MikeJSchorah No hosting just the .com domain name.
Mike
@MikeJSchorah
May 09 2017 02:43
@Giveback007 Actually, sending out applications for tech jobs is easy. :) It's not like other jobs where there is a lengthy process. I could apply to most jobs in less than 30 seconds apiece. I applied to 200 jobs yesterday alone.
Dovydas Stirpeika
@Giveback007
May 09 2017 02:44
@MikeJSchorah did you automate the process somehow?
Kristopherlb
@Kristopherlb
May 09 2017 02:45
@revisualize I get the positions.
Mike
@MikeJSchorah
May 09 2017 02:45
@Giveback007 WordPress pays pennies and it's not in demand, so there will be traveling to do to get a WordPress job regardless. And freelancing is like building a business, you start off with $0 and have to market to clients and that's very time and money consuming. I'd rather just spend a day a week applying to jobs and spend the rest of the time taking courses and whatnot.
Claudio Restifo
@Marmiz
May 09 2017 02:45

@MikeJSchorah that gets me critic as well:

I applied to 200 jobs yesterday alone

And how many of those 200 you were "realistically" a good candidate?
All the 200 were asking for a front-end J-Query/HTML/CSS developer with no experience?
If the answer is yes then means you need to focus on your self presentation.
If the answer is no means you have some skill lacking and probably is worth investing on those.

Mike
@MikeJSchorah
May 09 2017 02:46
@revisualize I'd have to pay for it. I know other people that became developers with less than what I have regarding my portfolio site.
Chris Jimenez
@cjimenez113
May 09 2017 02:46
ok thank you @revisualize
CamperBot
@camperbot
May 09 2017 02:46
cjimenez113 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3917 | @revisualize |http://www.freecodecamp.com/revisualize
Dovydas Stirpeika
@Giveback007
May 09 2017 02:46
@MikeJSchorah no man, I mean like do 2-3 projects online, just to have "experience" it will put you ahead of like 90% of the applicants who are siting in the same boat as you.
Mike
@MikeJSchorah
May 09 2017 02:47
@Giveback007 No automation. You just fill out so many that you expect what they will ask and not have to think as much. It becomes like an assembly line of rejection (or leads to tons of phone calls that lead to rejection).
Dovydas Stirpeika
@Giveback007
May 09 2017 02:47
@MikeJSchorah look dude, if you realy sent out 500 applications and you are having a hard time then there's something in your process that is not working. I don't want to come across as rude, just want to help
@MikeJSchorah no one here has the exact answers (i know I don't) just suggestions, but I'm confident that if you tried something different it might help. You've already invested so much time earning this valuable skill, might as well go all the way.
Mike
@MikeJSchorah
May 09 2017 02:51
@Marmiz I searched for a job back in January for 5 weeks. That's when I put in about 300 applications total. I was very specific with those jobs. If the specifically asked for something that I did not have, I didn't apply to those jobs, but that limited me. I was applying to jobs in a 200 mile radius... jobs that were 4 hours away! I think that turned off some employers. I did get close a couple of times, but either because I didn't have a security clearance (lengthy process) or I wasn't a local candidate or I didn't get the quiz finished in time or I didn't wan to travel 2 hours away for a WordPress job, nothing panned out. This time around, my strategy is different. This time, I'm just applying to local jobs. Even jobs that ask for 10 years of experience. I know people that got their first web developer job where they listed 2 years experience and settled for 0 and even if they have a job that needs 5 years of experience, they might have another job that is entry level.
@Giveback007 I have 4 projects in my portfolio and I've received compliments on my portfolio site.
HeebieGeeBee
@HeebieGeeBee
May 09 2017 02:53
why only 4?
Srinivas
@21stnomad
May 09 2017 02:53
anyone please tell me whats wrong with my code? i struck here..
var Bike = function() {
  var gear;
  this.getGear = function(){
    return gear;
  };
  this.setGear = function(rr){};
    gear = rr;
};

var myCar = new Car();

var myBike = new Bike();
myBike.setGear(4);
myBike.getGear();
myBike.setGear(3);
myBike.getGear();
myBike.setGear(1);
myBike.getGear();
Dovydas Stirpeika
@Giveback007
May 09 2017 02:54
@HeebieGeeBee I'm not sure I think he means client projects
HeebieGeeBee
@HeebieGeeBee
May 09 2017 02:54
@21stnomad your block for setGear is wrong
Dovydas Stirpeika
@Giveback007
May 09 2017 02:54
anyways I gtg sleep
talk to you all later
HeebieGeeBee
@HeebieGeeBee
May 09 2017 02:54
@Giveback007 i know im jsut saying why dont you just keep doing projects
not you him
Mike
@MikeJSchorah
May 09 2017 02:55
@Giveback007 I'm sure there is something wrong in my process. I could take the long route as I'm guessing you are leading me to where I spend a year applying to local jobs that are only listed as "junior" or "entry-level". I guess the question really boils down to: "How fast do you want it?" The job that I came from, I was an operations manager. They wanted 3 years of experience. I had 0. But, I was able to talk myself into the position and someone gave me a chance. That's all that it takes. Just 1 person out of 1000 to give you a chance. Sending out resumes is like marketing. Marketing is a numbers game.
@Giveback007 Yeah, it's tough. I did way more than what this site has showed me. But I guess it's all about not giving up
HeebieGeeBee
@HeebieGeeBee
May 09 2017 02:57
@MikeJSchorah projects are hwo you can show ppl what youre really capable of so i would just keep doing them
even if theyre just little apps you build in a day or two
Dovydas Stirpeika
@Giveback007
May 09 2017 02:58

@MikeJSchorah

@Giveback007 Yeah, it's tough. I did way more than what this site has showed me. But I guess it's all about not giving up

Don't just not give up by continuously applying, go to meet ups, network, reach out to relatives see if they need websites or know someone who does. Sooner or later you will be noticed by the quality of your work

Mike
@MikeJSchorah
May 09 2017 02:59
@HeebieGeeBee I'd rather put my best work in my portfolio. I have done many other things, but the 4 in my portfolio, I think are the best out of what I have done. I'm getting better and better. I figure that I might as well put my recent best stuff in.
@Giveback007 No the 4 projects are from Free Code Camp
Dovydas Stirpeika
@Giveback007
May 09 2017 03:00
@MikeJSchorah offer to redo websites. I'm working on two legitimate business websites, who one doesn't have a site and other has a shitty one
@MikeJSchorah does that include your portfolio and tribute page?
grfraser
@grfraser
May 09 2017 03:00
any help with Stand in Line ?

In Computer Science a queue is an abstract Data Structure where items are kept in order. New items can be added at the back of the queue and old items are taken off from the front of the queue.

Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.

Dovydas Stirpeika
@Giveback007
May 09 2017 03:01
@grfraser you are having the function call itself
grfraser
@grfraser
May 09 2017 03:02

function nextInLine(arr, item) {
  // Your code here
  var number=item;
  nextInLine(arr, item);
  return nextinLine(arr, item);  // Change this line
}

// Test Setup
var testArr = [1,2,3,4,5];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Dovydas Stirpeika
@Giveback007
May 09 2017 03:02
@grfraser that creates an infinite loop, browsers don't like that
Mike
@MikeJSchorah
May 09 2017 03:02
@Giveback007 I've tried meetups before. I just don't have time for them right now. I can't afford the gas money. I only went to 1 meetup. I got the 2 hour away WordPress job interview out of it. Someone else wanted to interview me for a job, but then he found out that I don't have any real world experience.
grfraser
@grfraser
May 09 2017 03:02
haha yeah thats what it said!
@Giveback007

function nextInLine(arr, item) {
  // Your code here

  return nextinLine(arr, item);  // Change this line
}

// Test Setup
var testArr = [1,2,3,4,5];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
that doesnt work either though
@Giveback007
Dovydas Stirpeika
@Giveback007
May 09 2017 03:03
@grfraser now you are returning the function, you are still doing an infinite loop
grfraser
@grfraser
May 09 2017 03:03
i dont understand how to implement queues, it diddnt really explain it
Dovydas Stirpeika
@Giveback007
May 09 2017 03:03
hold on 1 sec
grfraser
@grfraser
May 09 2017 03:03
okay np
Moisés Man
@moigithub
May 09 2017 03:04
@grfraser review array methods.. u already did.. pop push shift unshift
u need to use 2 of those mehtods
Mike
@MikeJSchorah
May 09 2017 03:04
@Giveback007 No. I did the portfolio with help from a Udemy course. I wouldn't put the Tribute page in their either. If I went solely on the FCC beginner's projects, I don't think I'd be getting as many calls as I'm getting.
Dovydas Stirpeika
@Giveback007
May 09 2017 03:04
https://www.w3schools.com/jsref/jsref_obj_array.asp
this is a reference for JS array manipulation
grfraser
@grfraser
May 09 2017 03:05
oh so return unshift.nextInLine
?
Dovydas Stirpeika
@Giveback007
May 09 2017 03:05
@grfraser find push() and also book mark this reference and try to understand the examples they give you
Nick Forlivio
@whackdev
May 09 2017 03:05
@grfraser you have to add more code
@grfraser push is a good start
grfraser
@grfraser
May 09 2017 03:06
but that adds. it needs to return something. hmm
Moisés Man
@moigithub
May 09 2017 03:06
no guessing.. read what those methods does.. how they work, what they return
then reread instructions
@grfraser you can tell it to do both!
grfraser
@grfraser
May 09 2017 03:07
working on it now
thanks @whackdev @Giveback007 @moigithub
CamperBot
@camperbot
May 09 2017 03:07
grfraser sends brownie points to @whackdev and @giveback007 and @moigithub :sparkles: :thumbsup: :sparkles:
:cookie: 270 | @whackdev |http://www.freecodecamp.com/whackdev
:cookie: 299 | @giveback007 |http://www.freecodecamp.com/giveback007
:star2: 3210 | @moigithub |http://www.freecodecamp.com/moigithub
Dovydas Stirpeika
@Giveback007
May 09 2017 03:08

@grfraser you usually don't want the function to return itself unless there's some conditions that would prevent it from looping to infinity.

https://www.w3schools.com/jsref/jsref_push.asp

Please realy take the time to review the array refrences it will speed your learning up

grfraser
@grfraser
May 09 2017 03:08
alright, ill read it. im just confused on how pushing an array would return a single interger
wouldnt it jusst return a larger array?
Nick Forlivio
@whackdev
May 09 2017 03:09
that further I get the more I realize it's read read and read some more
but there is so much out there
Dovydas Stirpeika
@Giveback007
May 09 2017 03:09
@grfraser I think you misunderstood the scope of that assignment
grfraser
@grfraser
May 09 2017 03:09
very true @whackdev i was speeding through the modules and i hit this one and got roadblocked
Christopher McCormack
@cmccormack
May 09 2017 03:09
@grfraser https://mdn.io/push - if you check the docs, there is a section that tells you specifically what a function returns
grfraser
@grfraser
May 09 2017 03:10
@Giveback007 nextInLine([], 1) should return 1 nextInLine([2], 1) should return 2 nextInLine([5,6,7,8,9], 1) should return 5 After nextInLine(testArr, 10), testArr[4] should be 10
nextInLine([], 1) should return 1
nextInLine([2], 1) should return 2
nextInLine([5,6,7,8,9], 1) should return 5
After nextInLine(testArr, 10), testArr[4] should be 10
Christopher McCormack
@cmccormack
May 09 2017 03:11

Return value

The new length property of the object upon which the method was called.
grfraser
@grfraser
May 09 2017 03:11
so return the first interger of the array\
Joseph
@revisualize
May 09 2017 03:11
@Kristopherlb Sorry, I went AFK for a second. How are you doing?
Dovydas Stirpeika
@Giveback007
May 09 2017 03:11
I already finished the intermediate algos and I still have a hard time reading trough MDN site. W3 is much simpler for beginner (I am one of those), I would hope more people would recommend it to those tow start out
nsonhouse
@nsonhouse
May 09 2017 03:11
Can someone explain how to extract a value form a JSON object?
Dovydas Stirpeika
@Giveback007
May 09 2017 03:11
@nsonhouse give me an object name
Gyniji
@Gyniji
May 09 2017 03:12
Can someone explain to me how an argument object works?
Joseph
@revisualize
May 09 2017 03:12
@MikeJSchorah Fuck what other people are doing. Who cares if people are able to get jobs with less than what you have.
nsonhouse
@nsonhouse
May 09 2017 03:12
How do I put the snippet of code in properly?
grfraser
@grfraser
May 09 2017 03:12
oh so return the length of the function? lol sorry i am so confused.
Nick Forlivio
@whackdev
May 09 2017 03:12
use 3 backticks
Christopher McCormack
@cmccormack
May 09 2017 03:12
@grfraser that's exactly what push returns :)
Joseph
@revisualize
May 09 2017 03:12

@grfraser Stand In Line is a CheckPoint where you're supposed to:
Write a function nextInLine which has two parameters
an array (arr) and a number (item).
That part has been done for you here:

function nextInLine(arr, item) { }

With that function declaration you have a function name of nextInLine. You have two parameters arr which represents an array passed into the function and item that represents a number passed to the function.
A few example function calls:

nextInLine([4,3,2] , 1) the values passed to arr is [4,3,2] and the value passed to item is 1

nextInLine([2,4,6,8] , 10) ... arr is [2,4,6,8] & item is 10

nextInLine([2,3,5,7,11] , 13) ... arr is [2,3,5,7,11] & item is 13 (first 5 and 6th prime numbers)

nextInLine([] , 0) ... arr is [] & item is 0

var myArr = [1,3,5,7]; nextInLine(myArr , 9) ... arr is [1,3,5,7] a copy of the value of the global variable myArr & item is 9

Parameters are treated like variables that represent the values that get passed into your function from the function call (arguments).

Again the two parameters for the nextInLine function are arr & item.

Per the instructions: Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.

You need to add the number (item) to the end of an array (arr).
You also need to remove the first element from an array (arr).

Then you need to have your function return the removed element from the array arr.

Dovydas Stirpeika
@Giveback007
May 09 2017 03:13
@nsonhouse do you know dot noration?
Joseph
@revisualize
May 09 2017 03:13
@MikeJSchorah Do you have enough money to buy a .com domain name?
Descyther
@descyther
May 09 2017 03:13
am i supposd to be using shift and push for this?:
Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.
Joseph
@revisualize
May 09 2017 03:14
@descyther Can you read that text that I just posted three lines up?
Descyther
@descyther
May 09 2017 03:14
will do ty
nsonhouse
@nsonhouse
May 09 2017 03:14
blob
grfraser
@grfraser
May 09 2017 03:15
@revisualize thank you for the clarification! let me see what i can do
CamperBot
@camperbot
May 09 2017 03:15
grfraser sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3918 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
May 09 2017 03:15
@MikeJSchorah You can get a .com domain name and point it to your github.io page.
Dovydas Stirpeika
@Giveback007
May 09 2017 03:15
@nsonhouse are you trying to access an API?
Gulsvi
@gulsvi
May 09 2017 03:15
@descyther Yes, shift() and push() would work well for that challenge.
Joseph
@revisualize
May 09 2017 03:15
@MikeJSchorah In fact, that's what I do with http://rvisualize.com/
nsonhouse
@nsonhouse
May 09 2017 03:15
I am trying to get to that number 22. This is the closest I can get.
Here is the JSON
[ RowDataPacket {
item_id: 1004,
product_name: 'Grand Harbour Umbrella',
department_name: 'Outdoor',
price: 69.99,
item_quantity: 22 } ]
Dovydas Stirpeika
@Giveback007
May 09 2017 03:16
(someone correct me if I am wrong) RowDataPacket.price // 69.99
Joseph
@revisualize
May 09 2017 03:16
@MikeJSchorah I don't have to pay for hosting. I just got the domain name and I've pointed it to my Github Pages URL. In fact, if you go to http://revisualize.github.io It forces you to redirect.
Christopher McCormack
@cmccormack
May 09 2017 03:17
@Giveback007 you're correct if they have already selected the correct index in the array
grfraser
@grfraser
May 09 2017 03:17

function nextInLine(arr, item) {
  // Your code here
  unshift.nextInLine[arr,item];
  return nextInLine(item);
  // Change this line
}

// Test Setup
var testArr = [1,2,3,4,5];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
it says unshift is not defined?
neither is push, etc
Dovydas Stirpeika
@Giveback007
May 09 2017 03:18
you can also do like this RowDataPacket['item_id'] // 1004
Christopher McCormack
@cmccormack
May 09 2017 03:18
@grfraser methods are called after the object, so try nextInLine.push(/*code*/) for example
Joseph
@revisualize
May 09 2017 03:19
@grfraser Why do you have the function name nextInLine inside of your function?
nsonhouse
@nsonhouse
May 09 2017 03:19
OK Im gonna try now
Joseph
@revisualize
May 09 2017 03:19
@grfraser nextInLine is a function not an Array.
Dovydas Stirpeika
@Giveback007
May 09 2017 03:19
@nsonhouse [ ] square brackets are best for things with spaces or using variables, did you catch my previous responses?
grfraser
@grfraser
May 09 2017 03:20
@SkyCoder01 nice visualization! @revisualize good point thank you retrying
CamperBot
@camperbot
May 09 2017 03:20
grfraser sends brownie points to @skycoder01 and @revisualize :sparkles: :thumbsup: :sparkles:
:warning: grfraser already gave revisualize points
:star2: 1327 | @skycoder01 |http://www.freecodecamp.com/skycoder01
Dovydas Stirpeika
@Giveback007
May 09 2017 03:21
@grfraser @revisualize it is in his name to visualize
grfraser
@grfraser
May 09 2017 03:21
hahaha @Giveback007

function nextInLine(arr, item) {
  // Your code here
  [arr,item].shift;
  return nextInLine(arr,item);
  // Change this line
}
maximum call stack exceeded
Dovydas Stirpeika
@Giveback007
May 09 2017 03:22
you keep returning the function
try to falow the logic of what you are doing
grfraser
@grfraser
May 09 2017 03:22
oh i thought i was supposed to
Joseph
@revisualize
May 09 2017 03:22
@grfraser Okay. You have some issues.
Dovydas Stirpeika
@Giveback007
May 09 2017 03:22
if you call the function and it returns the function which will return the function who in turn will return ....
Joseph
@revisualize
May 09 2017 03:22
@grfraser I think you really need to learn how to use basic array methods.
grfraser
@grfraser
May 09 2017 03:23
i know how, i just dont understand what im supposed to do i guess
Joseph
@revisualize
May 09 2017 03:23
@grfraser I think you need to take a step back and re-visit a few lessons.
grfraser
@grfraser
May 09 2017 03:23

function nextInLine(arr, item) {
  // Your code here
  return [arr,item].shift;
  // Change this line
}
nsonhouse
@nsonhouse
May 09 2017 03:23
@Giveback007 RowDataPacket is not defined
Joseph
@revisualize
May 09 2017 03:23
@grfraser That isn't even remotely correct.
nsonhouse
@nsonhouse
May 09 2017 03:23
at Query._callback
Dovydas Stirpeika
@Giveback007
May 09 2017 03:23
@nsonhouse where is the full object?
Aaron
@FallenPuppet
May 09 2017 03:24
按照下面的顺序,并且用空格来分割:
反斜杠 制表符 退格符 回车符 换行符 并把它赋值给变量 myStr
Joseph
@revisualize
May 09 2017 03:24
@grfraser Here: Can you redo these 4 lessons:
Manipulate Arrays With push()
Manipulate Arrays With pop()
Manipulate Arrays With shift()
Manipulate Arrays With unshift()
grfraser
@grfraser
May 09 2017 03:24
alright im gonna stop cloggin the chat and just figure it out on my own, sorry guys
nsonhouse
@nsonhouse
May 09 2017 03:24
@Giveback007 In a sql db
grfraser
@grfraser
May 09 2017 03:24
thank you for the help
@revisualize yes i know those
i was definitely forgetting the ()s
Dovydas Stirpeika
@Giveback007
May 09 2017 03:25
ahh... @cmccormack do you know sql object accessing? @nsonhouse needs help
Joseph
@revisualize
May 09 2017 03:25
@grfraser I'm not trying to be rude here. But, I have the feeling that you're forgetting a lot of things.
nsonhouse
@nsonhouse
May 09 2017 03:25
@Giveback007 I used connection.query('SELECT * FROM products WHERE item_id = ' + itemid, function(err, res){
Joseph
@revisualize
May 09 2017 03:26
@grfraser And that's okay. It just takes repetition to learn these concepts.
nsonhouse
@nsonhouse
May 09 2017 03:26
@Giveback007 The object is in res
grfraser
@grfraser
May 09 2017 03:26
@revisualize i understand completely, i feel dumb lol
@revisualize this should be simple
i am fairly new to js though
Dovydas Stirpeika
@Giveback007
May 09 2017 03:26
@grfraser don't feel bad.
grfraser
@grfraser
May 09 2017 03:27
hahah :smile:
Dovydas Stirpeika
@Giveback007
May 09 2017 03:27
@grfraser I was actualy stuck on that exact problem and then for 2 weeks took a break
Christopher McCormack
@cmccormack
May 09 2017 03:27
@grfraser keep looking at examples and try to understand the syntax fully, it really helps. Check MDN as well, there are some great examples - https://mdn.io/push https://mdn.io/shift
nsonhouse
@nsonhouse
May 09 2017 03:27
I feel dumb too. Your not alone.
Descyther
@descyther
May 09 2017 03:27
@SkyCoder01 thank you very much! Ive actually done what it asks and both adding and removing the correct element is showing in the console but it still doesnt work :/ oh well. I think this question should be removed because of the bad explination it gives.
CamperBot
@camperbot
May 09 2017 03:27
descyther sends brownie points to @skycoder01 :sparkles: :thumbsup: :sparkles:
:star2: 1329 | @skycoder01 |http://www.freecodecamp.com/skycoder01
Joseph
@revisualize
May 09 2017 03:27
@grfraser Don't feel bad. Everyone is at a different stage in their learning journey.
Dovydas Stirpeika
@Giveback007
May 09 2017 03:27
@grfraser after that I came back I knocked out javascript and felt that I was 'getting it' instead of trying to get it
grfraser
@grfraser
May 09 2017 03:28
ill think about it some more. i guess ithought i should just be able to blow thru these challenges but they are actually becoming challenging haha
Christopher McCormack
@cmccormack
May 09 2017 03:28
@Giveback007 @nsonhouse I've barely touched on SQL via JS but if you have a pen I could check it out
Joseph
@revisualize
May 09 2017 03:28
Let me post this one more time.

@grfraser Stand In Line is a CheckPoint where you're supposed to:
Write a function nextInLine which has two parameters
an array (arr) and a number (item).
That part has been done for you here:

function nextInLine(arr, item) { }

With that function declaration you have a function name of nextInLine. You have two parameters arr which represents an array passed into the function and item that represents a number passed to the function.
A few example function calls:

nextInLine([4,3,2] , 1) the values passed to arr is [4,3,2] and the value passed to item is 1

nextInLine([2,4,6,8] , 10) ... arr is [2,4,6,8] & item is 10

nextInLine([2,3,5,7,11] , 13) ... arr is [2,3,5,7,11] & item is 13 (first 5 and 6th prime numbers)

nextInLine([] , 0) ... arr is [] & item is 0

var myArr = [1,3,5,7]; nextInLine(myArr , 9) ... arr is [1,3,5,7] a copy of the value of the global variable myArr & item is 9

Parameters are treated like variables that represent the values that get passed into your function from the function call (arguments).

Again the two parameters for the nextInLine function are arr & item.

Per the instructions: Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.

You need to add the number (item) to the end of an array (arr).
You also need to remove the first element from an array (arr).

Then you need to have your function return the removed element from the array arr.

grfraser
@grfraser
May 09 2017 03:28
@Giveback007 ill check ot the book
ethanjoanna
@ethanjoanna
May 09 2017 03:28
how to send a picture?
nsonhouse
@nsonhouse
May 09 2017 03:29
@cmccormack I have not used pen. How do I set it up?
Dovydas Stirpeika
@Giveback007
May 09 2017 03:29
@grfraser or at least use this https://www.w3schools.com/jsref/ refrence and trying to understand the logic of it
Christopher McCormack
@cmccormack
May 09 2017 03:30
@nsonhouse just meant codepen.io, or repl.it or anywhere you can share your code
Gulsvi
@gulsvi
May 09 2017 03:30
@descyther It does confuse a lot of people :) main thing it tries to teach is how to use .push(), .pop(), .shift(), and .unshift(). Sounds like you have that mostly figured out :)
Dovydas Stirpeika
@Giveback007
May 09 2017 03:30
function addition(a, b) { 
return a + b;
}
what will this do @grfraser
Descyther
@descyther
May 09 2017 03:31
ahh thats alright then I guesss I'll skip it for now :)
Dovydas Stirpeika
@Giveback007
May 09 2017 03:32

@grfraser

function infin(a) {
return infin(7);
}

If you know the first one that you can imagine this one

ethanjoanna
@ethanjoanna
May 09 2017 03:33
lesson Profile Lookup how to do?
grfraser
@grfraser
May 09 2017 03:33
@revisualize nextInLine([2,3,5,7,11] , 13) ... arr is [2,3,5,7,11] & item is 13 (first 5 and 6th prime numbers) ? is there some math i am not implementing or is this simpler than i think? also where did you get those instructions??
Joseph
@revisualize
May 09 2017 03:34
@grfraser I was just making a side point.
@grfraser I wrote those instructions to help people see the challenge differently.
nsonhouse
@nsonhouse
May 09 2017 03:34
@cmccormack So, I hope I did this right. https://codepen.io/nSco/pen/vmppVw
Dovydas Stirpeika
@Giveback007
May 09 2017 03:34
alirght, I said I would leave before, now it's realy time to leave, thank you all, have a good night
nsonhouse
@nsonhouse
May 09 2017 03:35
@Giveback007 Thanl you for your help
@Giveback007 Thank you
CamperBot
@camperbot
May 09 2017 03:35
nsonhouse sends brownie points to @giveback007 :sparkles: :thumbsup: :sparkles:
:cookie: 300 | @giveback007 |http://www.freecodecamp.com/giveback007
ian
@EIsIncorrect
May 09 2017 03:35
Stuck on the word blanks js challenge.

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";
  // Your code below this line
  myNoun = "My " + myAdjective + myNoun + myVerb + myAdverb;

  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
ethanjoanna
@ethanjoanna
May 09 2017 03:35
@revisualize thank you but i can't open it
CamperBot
@camperbot
May 09 2017 03:35
ethanjoanna sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3919 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
May 09 2017 03:36
@EIsIncorrect Dopeoplewritelikethis? Or do people write like this?
Christopher McCormack
@cmccormack
May 09 2017 03:36
@nsonhouse what is connection? Is there more code you're using that you can't paste in your pen?
Jason Luboff
@JLuboff
May 09 2017 03:36
@nsonhouse still having trouble eh? Hmm..have you tried res[0].RowDataPacket?
Joseph
@revisualize
May 09 2017 03:36
@EIsIncorrect You need to add spaces between your words.
ian
@EIsIncorrect
May 09 2017 03:36
@revisualize Oh I see, thanks!
CamperBot
@camperbot
May 09 2017 03:36
eisincorrect sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3920 | @revisualize |http://www.freecodecamp.com/revisualize
nsonhouse
@nsonhouse
May 09 2017 03:37
@cmccormack Im connecting to a sql database
@JLuboff I'll try now
@JLuboff I think I tried that earlier
Christopher McCormack
@cmccormack
May 09 2017 03:37
@nsonhouse ok what is your full response you get back?
grfraser
@grfraser
May 09 2017 03:38
@revisualize what should i return if not the function itself?
arr.push(item);
   arr.pop(arr);
nsonhouse
@nsonhouse
May 09 2017 03:38
@JLuboff UNDEFINED
Joseph
@revisualize
May 09 2017 03:38
@grfraser Then you need to have your function return the removed element from the array arr.
@grfraser What does .pop() do?
nsonhouse
@nsonhouse
May 09 2017 03:39
@cmccormack [ RowDataPacket {
item_id: 1004,
product_name: 'Grand Harbour Umbrella',
department_name: 'Outdoor',
price: 69.99,
item_quantity: 22 } ]
grfraser
@grfraser
May 09 2017 03:39
pops the last number off the array
removes
how do i catch it ?
Joseph
@revisualize
May 09 2017 03:39
@grfraser Which element are you supposed to remove from the array?
grfraser
@grfraser
May 09 2017 03:39
the first one
damn it lol unshift
is what i need
Joseph
@revisualize
May 09 2017 03:40
@grfraser What does .unshift() do?
grfraser
@grfraser
May 09 2017 03:40
i mean shift :worried:
unshift adds to beginning
shift removes from beginning
Joseph
@revisualize
May 09 2017 03:40

@grfraser
The push() method adds one or more elements to the end of an array and returns the new length of the array.

The pop() method removes the last element from an array and returns that element.

The unshift() method adds one or more elements to the beginning of an array and returns the new length of the array.

The shift() method removes the first element from an array and returns that element.

grfraser
@grfraser
May 09 2017 03:41
can you explain what they mean by
After nextInLine(testArr, 10), testArr[4] should be 10
somehow this completes that requirement
function nextInLine(arr, item) {
  // Your code here
   arr.push(item);
   arr.shift(arr);
  // Change this line
Joseph
@revisualize
May 09 2017 03:42
@grfraser testArr is a global variable.
@grfraser There is no argument for .shift() it just does a thing.
grfraser
@grfraser
May 09 2017 03:42
ah yeah
good point same for pop
Joseph
@revisualize
May 09 2017 03:43
@grfraser So, what does .shift() return ?
grfraser
@grfraser
May 09 2017 03:43
the first number of the array
ethanjoanna
@ethanjoanna
May 09 2017 03:43
@revisualize thank you very much
CamperBot
@camperbot
May 09 2017 03:43
ethanjoanna sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: ethanjoanna already gave revisualize points
Gulsvi
@gulsvi
May 09 2017 03:43
var arr = [1,2,3];
return arr.push(9); // adds a 9 to the end and returns 4, the new array length. Now your array is [1,2,3,9]
return arr.unshift(8); // adds 8 to the beginning and returns 5, the new array length. Now your array is [8,1,2,3,9]
return arr.shift(); // removes from the beginning and returns 8, the item removed. Now your array is [1,2,3,9]
return arr.pop(); // removes from the end and returns 9, the item removed. Now your array is [1,2,3] again
Joseph
@revisualize
May 09 2017 03:43
@grfraser Not really but, okay. ... It returns the first element from the array.
grfraser
@grfraser
May 09 2017 03:44
yes first element
nsonhouse
@nsonhouse
May 09 2017 03:44

@JLuboff With this statement console.log(JSON.stringify(res, ["item_quantity"]));
I was able to get this output : [{"item_quantity":22}]

And here is the JSON:
[ RowDataPacket {
item_id: 1004,
product_name: 'Grand Harbour Umbrella',
department_name: 'Outdoor',
price: 69.99,
item_quantity: 22 } ]

Jason Luboff
@JLuboff
May 09 2017 03:44
@nsonhouse what about just res[0]?
Joseph
@revisualize
May 09 2017 03:44
@grfraser So, why can't your function just return what is returned from the .shift()?
Christian Krzekotowski da Cunha
@Krzek
May 09 2017 03:44
Whats up, guys!
nsonhouse
@nsonhouse
May 09 2017 03:45
@JLuboff [ RowDataPacket {
item_id: 1004,
product_name: 'Grand Harbour Umbrella',
department_name: 'Outdoor',
price: 69.99,
item_quantity: 22 } ]
Christopher McCormack
@cmccormack
May 09 2017 03:45
@nsonhouse so when you do console.log(qt) you get the response above? Have you tried console.log(qt[0].item_id or something like that to see if you get anything?
Christian Krzekotowski da Cunha
@Krzek
May 09 2017 03:45
I have a question about challenge "Profile Lookup"
nsonhouse
@nsonhouse
May 09 2017 03:45
@JLuboff YES SIR
grfraser
@grfraser
May 09 2017 03:46
@revisualize it only meets two of the requirements
nextInLine([2], 1) should return 2
nextInLine([5,6,7,8,9], 1) should return 5

function nextInLine(arr, item) {
  // Your code here
   return arr.shift();
nsonhouse
@nsonhouse
May 09 2017 03:46
@cmccormack THAT JUST WORKED
Christopher McCormack
@cmccormack
May 09 2017 03:47
@nsonhouse I figured - that RowDataPacket doesn't have an = or : so I think when you reference qt[0] you just get the object that RowDataPacket refers to
Christian Krzekotowski da Cunha
@Krzek
May 09 2017 03:48

If both are true, then return the "value" of that property.

If firstName does not correspond to any contacts then return "No such contact"

If prop does not correspond to any valid properties then return "No such property"

Christopher McCormack
@cmccormack
May 09 2017 03:48
not familiar with that syntax though
Joseph
@revisualize
May 09 2017 03:48
@grfraser What happened to the .push()?!!!!
grfraser
@grfraser
May 09 2017 03:48
@revisualize @SkyCoder01 great guide thank you. this passes all test cases but the second one

function nextInLine(arr, item) {
  // Your code here
   arr.shift();
   return arr.push(item);
  // Change this line
CamperBot
@camperbot
May 09 2017 03:48
grfraser sends brownie points to @revisualize and @skycoder01 :sparkles: :thumbsup: :sparkles:
:warning: grfraser already gave revisualize points
:warning: grfraser already gave skycoder01 points
grfraser
@grfraser
May 09 2017 03:48
ahahah @revisualize
Christian Krzekotowski da Cunha
@Krzek
May 09 2017 03:48

'''
function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i++) {
if (contacts[i].hasOwnProperty(prop)) {
if (contacts[i].firstName == firstName) {
return contacts[i][prop];

  } else { //ends if firstName
    return "No such contact";

  }// ends else firstName

} else { //ends if prop
  return "No such property";

} // ends else prop

} //ends for

// Only change code above this line
}'''

CamperBot
@camperbot
May 09 2017 03:48
:bulb: to format code use backticks! ``` more info
Joseph
@revisualize
May 09 2017 03:48
@grfraser Now you're doing things out of order!
Gabe Rotberg
@grotberg
May 09 2017 03:48
@Krzek That sounds about right. Where are you getting hung up?
grfraser
@grfraser
May 09 2017 03:49
okay okay hahah one sec
nsonhouse
@nsonhouse
May 09 2017 03:49
@cmccormack That is the way the data comes back from the database. I dont know why it prepends the JSON
Christian Krzekotowski da Cunha
@Krzek
May 09 2017 03:49
function lookUpProfile(firstName, prop){
// Only change code below this line
  for (var i = 0; i < contacts.length; i++) {    
    if (contacts[i].hasOwnProperty(prop)) {
      if (contacts[i].firstName == firstName) {
        return contacts[i][prop];

      } else { //ends if firstName
        return "No such contact";

      }// ends else firstName

    } else { //ends if prop
      return "No such property";

    } // ends else prop
  } //ends for

// Only change code above this line
}
grfraser
@grfraser
May 09 2017 03:49
omg @revisualize i got it

function nextInLine(arr, item) {
  // Your code here

    arr.push(item);
  return arr.shift();
  // Change this line
}
Gabe Rotberg
@grotberg
May 09 2017 03:49
@Krzek ah, it looks likat that first check for hasOwnProp is coming before you make sure you're looking at the right user
Joseph
@revisualize
May 09 2017 03:50
@grfraser Now look at your code and the instructions.
nsonhouse
@nsonhouse
May 09 2017 03:50
@cmccormack I thank you very much sir. I have been at this since 6:30pm
CamperBot
@camperbot
May 09 2017 03:50
nsonhouse sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 533 | @cmccormack |http://www.freecodecamp.com/cmccormack
Gabe Rotberg
@grotberg
May 09 2017 03:50
@Krzek remember, you need to determine if the user is there first, THEN if that user does exist, you need to figure out if it has the right property
Christopher McCormack
@cmccormack
May 09 2017 03:50
np
nsonhouse
@nsonhouse
May 09 2017 03:51
@JLuboff I thank you for your assistance as well.
console.log(res[0].item_quantity);
CamperBot
@camperbot
May 09 2017 03:51
nsonhouse sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 1709 | @jluboff |http://www.freecodecamp.com/jluboff
Christian Krzekotowski da Cunha
@Krzek
May 09 2017 03:51
@grotberg Thank you, very much! :3
CamperBot
@camperbot
May 09 2017 03:51
krzek sends brownie points to @grotberg :sparkles: :thumbsup: :sparkles:
:cookie: 345 | @grotberg |http://www.freecodecamp.com/grotberg
Gabe Rotberg
@grotberg
May 09 2017 03:51
@Krzek no problem, good luck!
grfraser
@grfraser
May 09 2017 03:51
im going to try to digest this a little more. obviously you are right, i dont know enough about how exactly they work. my brain is missing something. i will also do more reading on the subject. thank you so much though @revisualize are you a mod or something?
CamperBot
@camperbot
May 09 2017 03:51
grfraser sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: grfraser already gave revisualize points
ian
@EIsIncorrect
May 09 2017 03:52
@revisualize am I adding the spaces properly?
```
myNoun = "My " + myAdjective + " " + myNoun + " " + myVerb + " " + myAdverb;
Joseph
@revisualize
May 09 2017 03:52
@EIsIncorrect yes.
@EIsIncorrect But, I don't know why you're overwriting myNoun
@EIsIncorrect What is your function returning?
ian
@EIsIncorrect
May 09 2017 03:54
@revisualize nothing. can't pass the challenge still. This is what I got so far:
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";
  // Your code below this line
  myNoun = "My " + myAdjective + " " + myNoun + " " + myVerb + " " + myAdverb;

  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
Christopher McCormack
@cmccormack
May 09 2017 03:55
@EIsIncorrect what are you returning? Focus on that
Joseph
@revisualize
May 09 2017 03:56
@EIsIncorrect Your function has declared and initialized the variable result to "". You are not modifying result and your function is returning result. Ergo, you're returning "". You need to modify result.
grfraser
@grfraser
May 09 2017 03:56
@revisualize gotta keep it low key. i get it. thanks again though for your time! i cant believe i didnt see it at first now. lol
CamperBot
@camperbot
May 09 2017 03:56
grfraser sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: grfraser already gave revisualize points
Gabe Rotberg
@grotberg
May 09 2017 04:01
@monarkb you're nearly there, but look at the tests - you need two single quotes and four double quotes (you have the opposite)
ian
@EIsIncorrect
May 09 2017 04:02
Oh ok, I knew putting myNoun didn't make sense, but I didn't know what other variable to put
grfraser
@grfraser
May 09 2017 04:02
^^^
ian
@EIsIncorrect
May 09 2017 04:03
@cmccormack thanks for clarifying!
CamperBot
@camperbot
May 09 2017 04:03
eisincorrect sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 534 | @cmccormack |http://www.freecodecamp.com/cmccormack
ian
@EIsIncorrect
May 09 2017 04:03
@revisualize thanks again for clarifying!
CamperBot
@camperbot
May 09 2017 04:03
eisincorrect sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: eisincorrect already gave revisualize points
grfraser
@grfraser
May 09 2017 04:07
@revisualize how is this test case covered if 1 isnt even in the array though?
```
nextInLine([], 1) should return 1

additionally

After nextInLine(testArr, 10), testArr[4] should be 10

? the item at index 4 is a 5

Christopher McCormack
@cmccormack
May 09 2017 04:09
@grfraser you're supposed to put something in the array first

@grfraser

Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.

grfraser
@grfraser
May 09 2017 04:10
those are the test cases
Joseph
@revisualize
May 09 2017 04:10
@grfraser Look.
Christopher McCormack
@cmccormack
May 09 2017 04:11
@grfraser so if you add 1 to the array, then remove the first element of the array and return that value, wouldn't you expect 1?
grfraser
@grfraser
May 09 2017 04:11
oh im dumb
Joseph
@revisualize
May 09 2017 04:11
nextInLine([4,3,2] , 1) the values passed to arr is [4,3,2] and the value passed to item is 1
nextInLine([2,4,6,8] , 10) ... arr is [2,4,6,8] & item is 10
nextInLine([] , 0) ... arr is [] & item is 0
var myArr = [1,3,5,7]; nextInLine(myArr , 9) ... arr is [1,3,5,7] a copy of the value of the global variable myArr & item is 9
grfraser
@grfraser
May 09 2017 04:11
im not thinking properly tonight im sorry guys lol
i wasnt thinking in terms of parameters/arguments for some reason
Christopher McCormack
@cmccormack
May 09 2017 04:12
sleep on it, you need time for your diffuse mode thinking to sort everything you learn
grfraser
@grfraser
May 09 2017 04:12
yeah ive been stayin up way too late recently , thanks guys @cmccormack @revisualize have a good night!
CamperBot
@camperbot
May 09 2017 04:12
grfraser sends brownie points to @cmccormack and @revisualize :sparkles: :thumbsup: :sparkles:
:cookie: 535 | @cmccormack |http://www.freecodecamp.com/cmccormack
:warning: grfraser already gave revisualize points
Christopher McCormack
@cmccormack
May 09 2017 04:13
@grfraser night!
stevenadrien
@stevenadrien
May 09 2017 04:13
Hey guys, I was wondering if I could please get some help with thi s assignment

We have an array of objects representing different people in our contacts lists.

A lookUpProfile function that takes firstName and a property (prop) as arguments has been pre-written for you.

The function should check if firstName is an actual contact's firstName and the given property (prop) is a property of that contact.

If both are true, then return the "value" of that property.

If firstName does not correspond to any contacts then return "No such contact"

If prop does not correspond to any valid properties then return "No such property"

I guess my question is
questions* lol
Is the syntax if(contacts[i]==firstname)
{
}
correct?
Secondly, if that is the case, how do we go about verifying if a the given property is a property of that contact
Christopher McCormack
@cmccormack
May 09 2017 04:16
@stevenadrien contacts[i] would be an Object, and firstName is a string. You'll have to reference the property of the object
stevenadrien
@stevenadrien
May 09 2017 04:16
hmm
this is what I have so far
Christopher McCormack
@cmccormack
May 09 2017 04:16
stevenadrien
@stevenadrien
May 09 2017 04:16

function lookUpProfile(firstName, prop){
// Only change code below this line
for( int i=0; i<contacts.length;i++)
{
if(contacts[i]==firstName)
{
contacts[i].prop
}

}

ahh that makes sense
so if(contacts[i].hasOwnProperty(prop)
{
Christopher McCormack
@cmccormack
May 09 2017 04:17
@stevenadrien remember you'll need several conditionals for this exercise, and try not to return too early!
@stevenadrien yup pretty close, just check your closing tags
stevenadrien
@stevenadrien
May 09 2017 04:20
@cmccormack thank you so much man :)
CamperBot
@camperbot
May 09 2017 04:20
stevenadrien sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 536 | @cmccormack |http://www.freecodecamp.com/cmccormack
Christopher McCormack
@cmccormack
May 09 2017 04:20
@stevenadrien np
stevenadrien
@stevenadrien
May 09 2017 04:20
also how do you go about returning the "value" of the property??
store in a variable? like
Christopher McCormack
@cmccormack
May 09 2017 04:21
whenever you reference an object property, it returns the value
stevenadrien
@stevenadrien
May 09 2017 04:21
var value = contacts[i].prop?
Christopher McCormack
@cmccormack
May 09 2017 04:21
sure, you can store the return value in a variable, or you can return the whole thing
stevenadrien
@stevenadrien
May 09 2017 04:22
hmm how would you do that, if you don't mind me asking
Christopher McCormack
@cmccormack
May 09 2017 04:22
depends on if you need the value again later or if, once you receive the value, you are finished and want to return it
Traek Wells
@TraekWells
May 09 2017 04:22
If I post my solution for the ‘Where do I belong challenge’, can someone tell me how I could have done it better? Or should I not post a solution in here?
stevenadrien
@stevenadrien
May 09 2017 04:22
hmm let's go with the first one
Christopher McCormack
@cmccormack
May 09 2017 04:22
@stevenadrien remember that all functions or methods return something, so if you call a function, it returns a value. using return x where x is a function will also return the return of x
stevenadrien
@stevenadrien
May 09 2017 04:24
that makes sense
Christopher McCormack
@cmccormack
May 09 2017 04:24
@stevenadrien but remember return also breaks out of the current scope ( your function in this case ) so only use it when you're actually ready to use it (i.e. you found your matching name and property, or matching name with no matching property)
stevenadrien
@stevenadrien
May 09 2017 04:24
Got it. Thanks!
Christopher McCormack
@cmccormack
May 09 2017 04:25
@TraekWells you can share a link if you like
stevenadrien
@stevenadrien
May 09 2017 04:26
oh, one more thing
outputting statements in JS is done through system.log right?
so system.log("message goes here");
?
I keep forgetting >.> <.< XD
Christopher McCormack
@cmccormack
May 09 2017 04:27
@stevenadrien console.log(/* expression */)
stevenadrien
@stevenadrien
May 09 2017 04:27
console.log!
Got it!
haha I faileddd you :'(
stevenadrien
@stevenadrien
May 09 2017 04:32
This is what I ended up with

for( var i=0; i<contacts.length;i++)
{
if(contacts[i]==firstName)
{
if(contacts[i].hasOwnProperty(prop)==true)
{
var value=contacts[i].prop;
return value;
}

    if(contacts[i].hasOwnProperty(prop)==false)
      {
         console.log("No such property"); 
      }
  }

  else if(contacts[i]!=firstName)
    {
      console.log("No such contact");
    }

}

and these are the errors
"Kristian", "lastName" should return "Vos"
"Sherlock", "likes" should return ["Intriguing Cases", "Violin"]
"Harry","likes" should return an array
"Bob", "number" should return "No such contact"
"Akira", "address" should return "No such property"
Christopher McCormack
@cmccormack
May 09 2017 04:34
@stevenadrien if you surround your code in ``` it will look nicer. the ``` must be on their own line:
```
code
```
you can also edit your previous posts here
stevenadrien
@stevenadrien
May 09 2017 04:35
function lookUpProfile(firstName, prop){
// Only change code below this line
for( var i=0; i<contacts.length;i++)
  {
    if(contacts[i]==firstName)
      {
        if(contacts[i].hasOwnProperty(prop)==true)
        {
           var value=contacts[i].prop;
           return value;
        }

        if(contacts[i].hasOwnProperty(prop)==false)
          {
             console.log("No such property"); 
          }
      }

      else if(contacts[i]!=firstName)
        {
          console.log("No such contact");
        }
  }
// Only change code above this line
}
Christopher McCormack
@cmccormack
May 09 2017 04:36
@stevenadrien couple things - you didn't go back and fix your firstname check after your first question. Also you don't need to do the ...(prop)==false, just do an else
also that last else if isn't necessary. You'll want to check every contact, so you don't want to return No such contact until you've iterated over every item in your array
mandeepudp92
@mandeepudp92
May 09 2017 04:37
hey
Golf Code
I dont know how to calculate golf score
Christopher McCormack
@cmccormack
May 09 2017 04:38
@stevenadrien what's cool about returns is you can use them like a conditional. If you have other returns that will match first, you can make a final return that is a failure scenario at the bottom of your function without needing a conditional
@mandeepudp92 I believe the rules are in the instructions are they not?
mandeepudp92
@mandeepudp92
May 09 2017 04:39
they are.... but not getting what to do
stevenadrien
@stevenadrien
May 09 2017 04:39
@cmccormack how do you do this??
and good point about waiting to iterate through the array first
so Im thinking creating a boolean that keeps track of if firstName and prop has been found??
Christopher McCormack
@cmccormack
May 09 2017 04:40
function aEqualsB (a, b) {
   if (a === b) {
      return true;
   }
   return false;
}
@stevenadrien you only need to find a matching contact once, and if you find a matching contact, you should have a nested conditional to check if there is a matching property. In both scenarios - matching contact matching property and matching contact no matching property you return right away, so you don't really need to store the values.
mandeepudp92
@mandeepudp92
May 09 2017 04:42
@cmccormack ican i use new variable here
kerafyrm02
@kerafyrm02
May 09 2017 04:43
function golfScore(par, strokes) {


  switch(true){

    case (strokes == 1):
      return 'Hole-in-one!';

    case (strokes <= par -2):
      return 'Eagle';

    case (strokes == par - 1):
      return 'Birdie';

    case (strokes == par):
      return 'Par';

    case (strokes == par + 1):
      return 'Bogey';

    case (strokes == par + 2):
      return 'Double Bogey';

    default:
      return 'Go Home!';
  }

}

// Change these values to test
golfScore(5, 4);
clean ~
Christopher McCormack
@cmccormack
May 09 2017 04:43
@mandeepudp92 you're given the par and the strokes as arguments to your function. You need to go through each scenario and make sure you return the correct result
stevenadrien
@stevenadrien
May 09 2017 04:43
well idk how else to return the value of that property without storing it as a value?
Christopher McCormack
@cmccormack
May 09 2017 04:44
@stevenadrien you can return the result of an object lookup no problem
stevenadrien
@stevenadrien
May 09 2017 04:44
return contacts[i].prop works??
mandeepudp92
@mandeepudp92
May 09 2017 04:44
@kerafyrm02 switch case i havent reached thre
@cmccormack i t need to sloved with if and else if
Christopher McCormack
@cmccormack
May 09 2017 04:45

@stevenadrien go back to the challenge

Using Objects for Lookups

and see how you did it there

stevenadrien
@stevenadrien
May 09 2017 04:45
ok
haha i dont think a switch case will really help me out here
hmm
kerafyrm02
@kerafyrm02
May 09 2017 04:48
What are you stuck on steven?
stevenadrien
@stevenadrien
May 09 2017 04:48
Profile Lookup question
kerafyrm02
@kerafyrm02
May 09 2017 04:48
Can you link me it?
Christopher McCormack
@cmccormack
May 09 2017 04:48
@stevenadrien here's an example:
> var o = { 'a': '1', 'b': '2' }
> var foo = function(prop) {
   return o[prop];
}
> foo('b')
'2'
ahh that makes sense
I think Im still a little frazzled by how object-based JavaScript is, especially coming from languages like C++ and Java
kerafyrm02
@kerafyrm02
May 09 2017 04:49
ok i see the assignment.. where's your code at steven?
Christopher McCormack
@cmccormack
May 09 2017 04:50

@stevenadrien

var value=contacts[i].prop;
           return value;

you can just do return contacts[i].prop (although you should use bracket notation, not dot notation for this problem)

stevenadrien
@stevenadrien
May 09 2017 04:50

' ' '
function lookUpProfile(firstName, prop){
// Only change code below this line
for( var i=0; i<contacts.length;i++)
{
if(contacts[i]==firstName)
{
if(contacts[i].hasOwnProperty(prop)==true)
{
return contacts[i].prop;
}

    else
      {
         console.log("No such property"); 
      }
  }

  else
    {
      console.log("No such contact");
    }

}
// Only change code above this line
}
' ' '

kerafyrm02
@kerafyrm02
May 09 2017 04:50
wrong tic marks
Coy Sanders
@coymeetsworld
May 09 2017 04:52
@stevenadrien you don't want to print anything to console.log, you want to return strings
also you need to recheck the logic for determining no such contact
it isn't in the right place
kerafyrm02
@kerafyrm02
May 09 2017 04:52
well your first problem is your first if statement
Christopher McCormack
@cmccormack
May 09 2017 04:52
scroll up guys you're repeating a lot
stevenadrien
@stevenadrien
May 09 2017 04:53
function lookUpProfile(firstName, prop){
// Only change code below this line
for( var i=0; i<contacts.length;i++)
  {
    if(contacts[i]==firstName)
      {
        if(contacts[i].hasOwnProperty(prop)==true)
        {
           return contacts[i].prop;
        }

        else
          {
             console.log("No such property"); 
          }
      }

      else
        {
          console.log("No such contact");
        }
  }
// Only change code above this line
}
yeah
kerafyrm02
@kerafyrm02
May 09 2017 04:53
Steven what does contacts[0] = ?
stevenadrien
@stevenadrien
May 09 2017 04:54
Wouldn't that refer to the first array,
so firstName Akira, lastName, Laine, etc
?
kerafyrm02
@kerafyrm02
May 09 2017 04:54
Well your first if statement says contacts[0] == firstName
Santhosh Kumar Rajagiri
@santhu342
May 09 2017 04:54
i am stck in Word Blanks challenge
please help me
stevenadrien
@stevenadrien
May 09 2017 04:54
haha check again
if(contacts[i]==firstName)
kerafyrm02
@kerafyrm02
May 09 2017 04:55
yeah ... i starts off as 0
Christopher McCormack
@cmccormack
May 09 2017 04:55
@stevenadrien i'd recommend you take your console log statements out and put then around your test cases instead, and add your logic in your conditionals
Santhosh Kumar Rajagiri
@santhu342
May 09 2017 04:56
wordBlanks("dog", "big", "ran", "quickly") should contain all of the passed in words separated by non-word characters (and any additional words in your madlib)
kerafyrm02
@kerafyrm02
May 09 2017 04:56
contacts[0] will always fail to meet firstName
Santhosh Kumar Rajagiri
@santhu342
May 09 2017 04:56

my script is

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line

// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");

what can i do
stevenadrien
@stevenadrien
May 09 2017 04:56
ahhh
mandeepudp92
@mandeepudp92
May 09 2017 04:56
@cmccormack is the way
stevenadrien
@stevenadrien
May 09 2017 04:56
so contacts[i].firstName==firstName?
Greg Duncan
@GregatGit
May 09 2017 04:57
@stevenadrien contacts is an array of objects - so contact[i] is not going to equal a single value
mandeepudp92
@mandeepudp92
May 09 2017 04:57

@cmccormack
function golfScore(par, strokes) {
// Only change code below this line
if(strokes==1)
{
return "Hole-in-one";
}
else if(strokes<=par-2)
{
return "Eagle";
}
else if(par-1)
{
return "Birdie";
}
else if(par)
{
return "Par";
}
else if(par+1)
{
return "Bogey";
}
else if(par+2)
{
return "Double Bogey";
}
else if(strokes >=par+3)
{
return "Go Home";
}

// Only change code above this line
}

// Change these values to test
golfScore(5, 9);

kerafyrm02
@kerafyrm02
May 09 2017 04:57
I would recommend using all brackets,,.. but you could use .
Christopher McCormack
@cmccormack
May 09 2017 04:58
@mandeepudp92 you need to compare par with strokes in all of your conditionals
Nick Forlivio
@whackdev
May 09 2017 04:59
can someone check out my pen? I can't figure out why the info isn't displaying, the API call seems to be working and I've double checked the variables
https://codepen.io/whackdev/pen/oWomYN
Greg Duncan
@GregatGit
May 09 2017 04:59
@stevenadrien it also needs to loop through the entire array - then outside of your for loop return "No such contact";
Christopher McCormack
@cmccormack
May 09 2017 05:00
@whackdev your ajax call is asynchronous and the scope of data is only within the call. You need to either use Promises, or do the majority of your work within the ajax success function
Nick Forlivio
@whackdev
May 09 2017 05:01
@cmccormack sometimes I'm really stupid, thanks!!
CamperBot
@camperbot
May 09 2017 05:01
whackdev sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 537 | @cmccormack |http://www.freecodecamp.com/cmccormack
Christopher McCormack
@cmccormack
May 09 2017 05:01
@whackdev everyone makes that same mistake, trust me :D
mandeepudp92
@mandeepudp92
May 09 2017 05:02
@cmccormack thnks for help
Christopher McCormack
@cmccormack
May 09 2017 05:02
@mandeepudp92 np
mandeepudp92
@mandeepudp92
May 09 2017 05:02
np????
kerafyrm02
@kerafyrm02
May 09 2017 05:03
No problem = np
stevenadrien
@stevenadrien
May 09 2017 05:03
hehe didnt realize I was building an algorithm derr
mandeepudp92
@mandeepudp92
May 09 2017 05:03
ok
kerafyrm02
@kerafyrm02
May 09 2017 05:03
Use contacts[i][firstName]
shamathakur
@shamathakur
May 09 2017 05:03
hi frnds
stevenadrien
@stevenadrien
May 09 2017 05:03
got caught up in the whole this is an assignment derderr
shamathakur
@shamathakur
May 09 2017 05:04

Strokes Return
1 "Hole-in-one!"
<= par - 2 "Eagle"
par - 1 "Birdie"
par "Par"
par + 1 "Bogey"
par + 2 "Double Bogey"

= par + 3 "Go Home!"

golfScore(4, 1) should return "Hole-in-one!"
golfScore(4, 2) should return "Eagle"
golfScore(5, 2) should return "Eagle"
golfScore(4, 3) should return "Birdie"
golfScore(4, 4) should return "Par"
golfScore(1, 1) should return "Hole-in-one!"
golfScore(5, 5) should return "Par"
golfScore(4, 5) should return "Bogey"
golfScore(4, 6) should return "Double Bogey"
golfScore(4, 7) should return "Go Home!"
golfScore(5, 9) should return "Go Home!"
how to solve this
kerafyrm02
@kerafyrm02
May 09 2017 05:04
use strokes == par -1
stevenadrien
@stevenadrien
May 09 2017 05:04
wait
shamathakur
@shamathakur
May 09 2017 05:04
plzz explain me
stevenadrien
@stevenadrien
May 09 2017 05:04
so is contacts[i].firstName valid
mandeepudp92
@mandeepudp92
May 09 2017 05:04
@shamathakur compare strokes with par
stevenadrien
@stevenadrien
May 09 2017 05:05
or do i havee to cuse contacts[i][firstName]?
use*
shamathakur
@shamathakur
May 09 2017 05:05
how to write condition in if else statement
kerafyrm02
@kerafyrm02
May 09 2017 05:05
contacts[i].firstName is valid if the property is literally spelled "firstName"
mandeepudp92
@mandeepudp92
May 09 2017 05:06
@shamathakur try with some wrong codes
after few trials ull get it
kerafyrm02
@kerafyrm02
May 09 2017 05:06
dot notation uses literal spelling wheras brackets allows variables
shamathakur
@shamathakur
May 09 2017 05:07
not getting after trial
stevenadrien
@stevenadrien
May 09 2017 05:07
for my reference, could you please show me how to use brackets?
mandeepudp92
@mandeepudp92
May 09 2017 05:07
@shamathakur code pls
kerafyrm02
@kerafyrm02
May 09 2017 05:07
contacts[i].property
vs
contacts[i][property]
top one is dot notation
bottom is bracket
stevenadrien
@stevenadrien
May 09 2017 05:08
Thank you @kerafyrm02
CamperBot
@camperbot
May 09 2017 05:08
stevenadrien sends brownie points to @kerafyrm02 :sparkles: :thumbsup: :sparkles:
:cookie: 164 | @kerafyrm02 |http://www.freecodecamp.com/kerafyrm02
kerafyrm02
@kerafyrm02
May 09 2017 05:08
if i set property = 'peanut'
then it would be like doing
mandeepudp92
@mandeepudp92
May 09 2017 05:08
@shamathakur convert this code to else if
function golfScore(par, strokes) {


  switch(true){

    case (strokes == 1):
      return 'Hole-in-one!';

    case (strokes <= par -2):
      return 'Eagle';

    case (strokes == par - 1):
      return 'Birdie';

    case (strokes == par):
      return 'Par';

    case (strokes == par + 1):
      return 'Bogey';

    case (strokes == par + 2):
      return 'Double Bogey';

    default:
      return 'Go Home!';
  }

}

// Change these values to test
golfScore(5, 4);
kerafyrm02
@kerafyrm02
May 09 2017 05:08
contacts[i]['peanut']
Hey... thats my code!
:P
mandeepudp92
@mandeepudp92
May 09 2017 05:10
@kerafyrm02 yeah thanks to you too
CamperBot
@camperbot
May 09 2017 05:10
:cookie: 165 | @kerafyrm02 |http://www.freecodecamp.com/kerafyrm02
mandeepudp92 sends brownie points to @kerafyrm02 :sparkles: :thumbsup: :sparkles:
DrFillGood
@DrFillGood
May 09 2017 05:10
Hey! If you guys aren't too busy I was just wondering if you could tell me what I'm doing wrong in my 'Check for Palindromes' challenge on freeCodeCamp!

///var a = "";
var b = "";
function palindrome(str) {
str.toLowerCase();
var x = str.replace(/\W+/g, "");
var length = x.length;
var middle = (length/2);
if (length % 2 !== 0){
var a = (x.substring(0, middle));
var b = (x.substring(middle + 1));

} else {
a = (x.substring(0, middle));
b = (x.substring(middle));
}
for (var i = b.length - 1, o = ''; i >= 0; o += b[i--]) {}
if (a.localeCompare(o) === 0){
return true;
} else {
return false;
}

// Good luck!

}

palindrome("ey_e");///

sorry for how gross it looks
kerafyrm02
@kerafyrm02
May 09 2017 05:10
  1. You're not using regex lol
DrFillGood
@DrFillGood
May 09 2017 05:11
hmmmmmm yeah i could see that being a limiting factor
so how would you remove nonalphanumeric char's without regex?
kerafyrm02
@kerafyrm02
May 09 2017 05:11
You should be using regex.
It's a super easy with regex.
DrFillGood
@DrFillGood
May 09 2017 05:12
thought that I put it in with the /\W+/g
to remove the stuff, but that removes the spaces but not any characters outside of whitespace
kerafyrm02
@kerafyrm02
May 09 2017 05:13
I think you misunderstand what \W covers
DrFillGood
@DrFillGood
May 09 2017 05:13
ahhh so would be better to do {^a-z] style instead?
kerafyrm02
@kerafyrm02
May 09 2017 05:14
It's best to go piece by piece.
Which items does it ask to filter?
DrFillGood
@DrFillGood
May 09 2017 05:14
all non-alpha-numeric items and spaces
kerafyrm02
@kerafyrm02
May 09 2017 05:15
\w is same as [A-Za-z0-9_]
DrFillGood
@DrFillGood
May 09 2017 05:16
capitalised was supposedly the inverse of that, but hasn't been working out.
kerafyrm02
@kerafyrm02
May 09 2017 05:16
It is
\W == [^\w]
or not \w
my suggestion is to filter the good
split it
reverse it
and compare to copy
stevenadrien
@stevenadrien
May 09 2017 05:17
loll
kinda lost now XD
here's what I got

`
function lookUpProfile(firstName, prop){
// Only change code below this line
var nameFound=false;
var propFound=false;

var propValue;

for( var i=0; i<contacts.length;i++)
{
if(contacts[i].firstName==firstName)
{

    nameFound=true;
    if(contacts[i].hasOwnProperty(prop)===true)
    {
      propFound=true; 
      propValue=contacts[i].prop;
    }

    if(contacts[i].hasOwnProperty(prop)===false)
    {
       propFound=false;
    }


  }

 if(contacts[i].firstName!=firstName)
   {
      nameFound=false;
   }

}

if(nameFound===false)
{
console.log("No such contact");
}

if(propFound===false)
{
console.log("No such property");
}

return propValue;

// Only change code above this line
}
`

`
function lookUpProfile(firstName, prop){
// Only change code below this line
var nameFound=false;
var propFound=false;

var propValue;

for( var i=0; i<contacts.length;i++)
{
if(contacts[i].firstName==firstName)
{

    nameFound=true;
    if(contacts[i].hasOwnProperty(prop)===true)
    {
      propFound=true; 
      propValue=contacts[i].prop;
    }

    if(contacts[i].hasOwnProperty(prop)===false)
    {
       propFound=false;
    }


  }

 if(contacts[i].firstName!=firstName)
   {
      nameFound=false;
   }

}

if(nameFound===false)
{
console.log("No such contact");
}

if(propFound===false)
{
console.log("No such property");
}

return propValue;

// Only change code above this line
}
`

kerafyrm02
@kerafyrm02
May 09 2017 05:19
var test = 'abcde';
var copy = test.replace('/\W\s/gi', '');
stevenadrien
@stevenadrien
May 09 2017 05:19
function lookUpProfile(firstName, prop){
// Only change code below this line
var nameFound=false;
var propFound=false;

var propValue;

  for( var i=0; i<contacts.length;i++)
  {
    if(contacts[i].firstName==firstName)
      {

        nameFound=true;
        if(contacts[i].hasOwnProperty(prop)===true)
        {
          propFound=true; 
          propValue=contacts[i].prop;
        }

        if(contacts[i].hasOwnProperty(prop)===false)
        {
           propFound=false;
        }


      }

     if(contacts[i].firstName!=firstName)
       {
          nameFound=false;
       }
  }

  if(nameFound===false)
    {
      console.log("No such contact");
    }

  if(propFound===false)
    {
      console.log("No such property");
    }

  return propValue;


// Only change code above this line
}
sorry about that
DrFillGood
@DrFillGood
May 09 2017 05:20
ahhhh k, so match instead of replace?
kerafyrm02
@kerafyrm02
May 09 2017 05:21
You can match or replace
replace the bad characters out
This message was deleted