These are chat archives for FreeCodeCamp/HelpJavaScript

2nd
May 2017
jusgoose
@gusd773
May 02 2017 00:00
@Lumexralph idk what u mean
blob
Jason Luboff
@JLuboff
May 02 2017 00:01
@Lumexralph Going home now! Adios
jusgoose
@gusd773
May 02 2017 00:01
that's what I have so far @Lumexralph
Ogundele Olumide
@Lumexralph
May 02 2017 00:01
@gusd773
1.1.1  check if the objects picked has the firstName property equal to the firstName parameter
                  1.1.1.1 you need to check if it has a property prop
                                  return the value of prop in the object
@JLuboff Tschuus!
jusgoose
@gusd773
May 02 2017 00:04
blob
aRtoo
@artoodeeto
May 02 2017 00:04
hi guys. quick question why is it JS isnt following the PMDAS rule??
heres the code.

function randomRange(myMin, myMax) {

  return Math.floor(Math.random() * (myMax - myMin + 1)) + myMin; // Change this line

}

// Change these values to test your function
var myRandom = randomRange(5, 15);
Ogundele Olumide
@Lumexralph
May 02 2017 00:06
@gusd773
Here's an outline, if you follow it step-wise it'll help a great deal in telling you what to do or step you missed
1. you need a loop to pick each objects in the contacts array
    1.1  in the loop you need to 
         1.1.1  check if the objects picked has the firstName property equal to the firstName parameter
                  1.1.1.1 you need to check if it has a property prop
                                  return the value of prop in the object
                 1.1.1.2  return no such property if  1.1.1.1 is false
2.  when your loop is done looking through  contacts return no such contact
@artoodeeto (myMax - myMin + 1) in JS + has higher precedence over -, what unusual behaviour did you notice?
aRtoo
@artoodeeto
May 02 2017 00:09
@Lumexralph ohh. its not follwing the PMDAS rule. i was confused. thanks
CamperBot
@camperbot
May 02 2017 00:09
artoodeeto sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1616 | @lumexralph |http://www.freecodecamp.com/lumexralph
colegottdank
@colegottdank
May 02 2017 00:15
how do you post code?
Ogundele Olumide
@Lumexralph
May 02 2017 00:16
@colegottdank '''
CamperBot
@camperbot
May 02 2017 00:16
:bulb: to format code use backticks! ``` more info
Ogundele Olumide
@Lumexralph
May 02 2017 00:16
@colegottdank click on the more info link
CamperBot
@camperbot
May 02 2017 00:16
:bulb: to format code use backticks! ``` more info
:bulb: to format code use backticks! ``` more info
colegottdank
@colegottdank
May 02 2017 00:17
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
  if(myObj.hasOwnProperty("checkProp"))
    {
      return myObj.checkProp;
    }

  return "Not Found";
}

// Test your code by modifying these values
checkObj("gift");
Ogundele Olumide
@Lumexralph
May 02 2017 00:17
@colegottdank you need to check the parameter checkProp not string "checkProp" and you need to use bracket notation to access the object myObj with a parameter
colegottdank
@colegottdank
May 02 2017 00:18
says it's better written in dot notation
Eduar Tua
@eduartua
May 02 2017 00:19

guys, I am getting the following error with:

$(document).ready(function() {
  $("button").on("click", function(){
    $.getJSON("http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1", function(json){
      //var html = "";
      console.log("success");
      console.log(json);
    })
    .done(function() {
      console.log( "second success" );
    })
    .fail(function() {
      console.log( "error" );
    })
    .always(function() {
      console.log( "complete" );
    });  
  });
});

Uncaught TypeError: Cannot read property 'ready' of undefined

colegottdank
@colegottdank
May 02 2017 00:20
Well, it tells me it's better written in dot notation, but then the bracket notation passed :/
Thank you @Lumexralph
CamperBot
@camperbot
May 02 2017 00:20
colegottdank sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1617 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
May 02 2017 00:20
@colegottdank there're exceptions..... Object.objectProperty is same as Object["objectProperty"]..... when executed
colegottdank
@colegottdank
May 02 2017 00:21
@eduartua Just a shot in the dark here, you supposed to put ; after the 3 )?
Eduar Tua
@eduartua
May 02 2017 00:22
Where?
@colegottdank
colegottdank
@colegottdank
May 02 2017 00:22
next line after the console.logs
i could be completely wrong..
caleb95hunter
@caleb95hunter
May 02 2017 00:22
Working on this WordBlanks thing in the JavaScript lessons... Where do I even start with it?
Damien
@DubbDevs
May 02 2017 00:24
I'm back at it with the counting card function
colegottdank
@colegottdank
May 02 2017 00:24
nice @DubbDevs and gl @caleb95hunter :P
Damien
@DubbDevs
May 02 2017 00:24
I've got the math working but need some assistance with returning the strings
colegottdank
@colegottdank
May 02 2017 00:25
what's the problem with it?
Damien
@DubbDevs
May 02 2017 00:25
I'm unsure if I need a another function or somehow add the string after the count
Ogundele Olumide
@Lumexralph
May 02 2017 00:25
@caleb95hunter start with concatenating the parameters and separate them with spaces " " and assign the string to result
Damien
@DubbDevs
May 02 2017 00:25

```var count = 0;

function cc(card) {
// Only change code below this line
switch (card) {
case 2:
case 3:
case 4:
case 5:
case 6:
count += 1;
break;
case 7:
case 8:
case 9:
count -= 0;
break;
case 10:
case "J":
case "K":
case "Q":
case "A":
count -= 1;
break;
}

return count;
// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(7); cc(3); cc(7); cc('K'); cc('A');```

colegottdank
@colegottdank
May 02 2017 00:26
Write the three back dashes, then write the language. For this, from js after the 3 backslashes
Damien
@DubbDevs
May 02 2017 00:26
my apologies
colegottdank
@colegottdank
May 02 2017 00:26
and yes, concatenate the parameters*
Damien
@DubbDevs
May 02 2017 00:26
var count = 0;

function cc(card) {
  // Only change code below this line
  switch (card) {
      case 2:
      case 3:
      case 4:
      case 5:
      case 6:
        count += 1;
         break;
      case 7:
      case 8:
      case 9:
        count -= 0;
         break;
      case 10:
      case "J":
      case "K":
      case "Q":
      case "A":
        count -= 1;
         break;
  }

  return count;
  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(7); cc(3); cc(7); cc('K'); cc('A');
Ogundele Olumide
@Lumexralph
May 02 2017 00:27
@DubbDevs you need an if statement to check if count is positive or negative, then you return count + the assosciated string
colegottdank
@colegottdank
May 02 2017 00:27
just for shits: you can do count--; or count++; to add 1 or subtract 1 from a num
Damien
@DubbDevs
May 02 2017 00:29
so it'll look something like if count <= 0 Hold else Bet
Ogundele Olumide
@Lumexralph
May 02 2017 00:29
@DubbDevs with count
Damien
@DubbDevs
May 02 2017 00:30
right...I had something similar and deleted because it couldn't figure out how to add it to the count...if all I had to do was add + string slaps forehead
Ogundele Olumide
@Lumexralph
May 02 2017 00:31
@DubbDevs yeah
colegottdank
@colegottdank
May 02 2017 00:31
@Lumexralph for js, they call vars with numbers, numbers? There is no other name like other languages? just called numbers?
Ogundele Olumide
@Lumexralph
May 02 2017 00:32
@colegottdank can make the question a bit clearer?
Damien
@DubbDevs
May 02 2017 00:33
does my if statement need to be in a new function or can I simply write it before the return
colegottdank
@colegottdank
May 02 2017 00:33
the data type is called numbers. in java, python, c, etc, they are called ints, or doubles depending on their size. in Javascript, it is just numbers?
same function before return
Ogundele Olumide
@Lumexralph
May 02 2017 00:33
@DubbDevs write it after the switch statement
@colegottdank floats and Integers
colegottdank
@colegottdank
May 02 2017 00:34
ah ok, thanks.
Damien
@DubbDevs
May 02 2017 00:34
@Lumexralph @colegottdank thanks! off to go figure that out
CamperBot
@camperbot
May 02 2017 00:34
dubbdevs sends brownie points to @lumexralph and @colegottdank :sparkles: :thumbsup: :sparkles:
:cookie: 208 | @colegottdank |http://www.freecodecamp.com/colegottdank
:star2: 1618 | @lumexralph |http://www.freecodecamp.com/lumexralph
colegottdank
@colegottdank
May 02 2017 00:34
floats for decimals and longer values? is that correct?
Ogundele Olumide
@Lumexralph
May 02 2017 00:34
@colegottdank I think so
@DubbDevs okay
colegottdank
@colegottdank
May 02 2017 00:35
googled, apparently it is all called numbers
they are all 64 bit floats. every 'number'
So, Javascript is pretty shit for memory? Compared to c at least lol. what isnt...
Ogundele Olumide
@Lumexralph
May 02 2017 00:36
@colegottdank hmmm...... guess i used my terms
@colegottdank C is mid-level language compared to JS a higher-level language
Damien
@DubbDevs
May 02 2017 00:37
@Lumexralph @colegottdank got it!
colegottdank
@colegottdank
May 02 2017 00:37
yeah, js seems even higher level than java
nice!
Ogundele Olumide
@Lumexralph
May 02 2017 00:37
@colegottdank I don't think so
colegottdank
@colegottdank
May 02 2017 00:39
lol, http://www.codecommit.com/blog/java/defining-high-mid-and-low-level-languages apparently it is, but it is subjective also. some ppl call javascript low level..
Eduar Tua
@eduartua
May 02 2017 00:42
How can I test a JQuery function i the browser without creating files? I mean, By using the console
Dan Couper
@DanCouper
May 02 2017 00:43
easiest is just open a page with jquery loaded, you should be able to use it in the console. For example, the jquery site
Ogundele Olumide
@Lumexralph
May 02 2017 00:43
@eduartua just console.log() whatever you want from the jQuery code
Eduar Tua
@eduartua
May 02 2017 00:44
@DanCouper thank you guys @Lumexralph
CamperBot
@camperbot
May 02 2017 00:44
eduartua sends brownie points to @dancouper and @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 682 | @dancouper |http://www.freecodecamp.com/dancouper
:star2: 1619 | @lumexralph |http://www.freecodecamp.com/lumexralph
barki mustapha
@barkinet
May 02 2017 00:45

Smart pane switching with awareness of Vim splits.

See: https://github.com/christoomey/vim-tmux-navigator

is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\S+\/)?g?(view|n?vim?x?)(diff)?$'"
bind-key -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L"
bind-key -n C-j if-shell "$is_vim" "send-keys C-j" "select-pane -D"
bind-key -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -U"
bind-key -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R"
bind-key -n C-\ if-shell "$is_vim" "send-keys C-\" "select-pane -l"

syntax on

set nocompatible
set smartindent
set shiftwidth=4
set backspace=indent,eol,start
set ruler
set number
set showcmd
set incsearch
set hlsearch

set mouse=a

filetype off

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim

"-------------- PLUGINS STARTS -----------------
call vundle#begin()

Plugin 'VundleVim/Vundle.vim'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'altercation/vim-colors-solarized'
Plugin 'scrooloose/nerdtree'
Plugin 'jistr/vim-nerdtree-tabs'
Plugin 'scrooloose/syntastic'
Plugin 'xolox/vim-misc'
Plugin 'xolox/vim-easytags'
Plugin 'majutsushi/tagbar'
Plugin 'ctrlpvim/ctrlp.vim'
Plugin 'vim-scripts/a.vim'
Plugin 'airblade/vim-gitgutter'
Plugin 'tpope/vim-fugitive'
Plugin 'Raimondi/delimitMate'
Plugin 'christoomey/vim-tmux-navigator'
Plugin 'jez/vim-c0'
Plugin 'jez/vim-ispc'
Plugin 'kchmck/vim-coffee-script'
Plugin 'flazz/vim-colorschemes'

call vundle#end()
"-------------- PLUGINS END --------------------
filetype plugin indent on

"----- GENERAL SETTINGS-------
set laststatus=2
let g:airline_powerline_fonts = 1
let g:airline_detect_paste=1
let g:airline#extensions#tabline#enabled = 1
let g:airline_theme='solarized'
set background=dark
let g:solarized_termcolors=256
colorscheme solarized

"---------NERD-TREE SETTINGS----------
nmap <silent> <leader>t :NERDTreeTabsToggle<CR>
let g:nerdtree_tabs_open_on_console_startup = 1

"-------- SYNTASTIC SETTINGS---------
let g:syntastic_error_symbol = '✘'
let g:syntastic_warning_symbol = "▲"

augroup mySyntastic
au!
au FileType tex let b:syntastic_mode = "passive"
augroup END

"-------- TAGS SETTINGS --------------------------------
let g:easytags_events = ['BufReadPost', 'BufWritePost']
let g:easytags_async = 1
let g:easytags_dynamic_files = 2
let g:easytags_resolve_links = 1
let g:easytags_suppress_ctags_warning = 1
let g:tagbar_autoclose=2

nmap <silent> <leader>b :TagbarToggle<CR>
"autocmd BufEnter * nested :call tagbar#autoopen(0)

"---------GIT SETTINGS--------------
hi clear SignColumn
let g:airline#extensions#hunks#non_zero_only = 1

"----------DELIMITEMATE SETTINGS-----------------
let delimitMate_expand_cr = 1
augroup mydelimitMate
au!
au FileType markdown let b:delimitMate_nesting_quotes = [""] au FileType tex let b:delimitMate_quotes = "" au FileType tex let b:delimitMate_matchpairs = "(:),[:],{:},:'"
au FileType python let b:delimitMate_nesting_quotes = ['"', "'"]
augroup END

"-----------TMUX SETTINGS--------------
let g:tmux_navigator_save_on_switch = 2

Davis Jaunbruns
@davis4acca
May 02 2017 00:50
Hello Everyone!

Could someone please be so kind and help me solve this issue?


$.ajax({
 type: 'GET',
 url: 'https://api.twitch.tv/kraken/users/freecodecamp/follows/channels/',
 headers: {
   'Client-ID': 'z883rj9plwsizbshb82r0fnsjclr7f'
 },
 success: function(data) {
createUserList();
 }
});




function createUserList(){
  var userList= [];
  for(i=0; i < data.follows.length; i++){
    userList.push(data.follows[i]);
  }

   console.log(userList[0].channel.display_name);
   $('#user-list').append('<li class="user"> <span class="logo"> Logo </span> <span class="user-name">'+userList[0].channel.display_name +' </span> <span class="status"> Status: </span>  </li>');
}

I want to run the createUserList function inside the ajax > success function. How can i call the createUserList function so it changes its context accordingly?

Christopher McCormack
@cmccormack
May 02 2017 00:56
@davis4acca pass your data object
or pass createUserList as your callback to success
khanvuthy88
@khanvuthy88
May 02 2017 01:06
Dear all members here, please kindly help me with this one, I need your help.
var ourArr = [ 9, 10, 11, 12];
var ourTotal = 0;

for (var i = 0; i < ourArr.length; i++) {
  ourTotal += ourArr[i];
}

// Setup
var myArr = [ 2, 3, 4, 5, 6];
var total=0;
for(var i=1;i>myArr.length;i++){
  total+=myArr[i];
}
Christopher McCormack
@cmccormack
May 02 2017 01:07
@khanvuthy88 what’s the goal?
khanvuthy88
@khanvuthy88
May 02 2017 01:07
why total is not equal to 20
Ian Arsenault
@ianarsenault
May 02 2017 01:07
Is there anyway to use a decrement loop but inside the loop make the index as if it were incrementing? So if i= arr.length; // 3 i--; in the loop I want to use it starting out at 0? Is there a way to use a modulo operator?
var i = digits.length,
    placeValNum,
    idx = 0;

while (i--) {
    // Get index of i to use in removal
    idx = digits.indexOf(i);
    // Get place value of number
    placeValNum = placeValues(digits[i], digits.length);
    // Push each place value integer into an array
    placeValueArray.push(placeValNum);
    // Remove that index
    digits.splice(idx, 1);
}

return placeValueArray; // Should return [300, 40, 2]
// Is returning [200, 40, 3] instead
Corri Taylor
@corritaylor
May 02 2017 01:08
I think I’m missing something very basic

// Setup
var myStorage = {
  "car": {
    "inside": {
      "glove box": "maps",
      "passenger seat": "crumbs"
     },
    "outside": {
      "trunk": "jack"
    }
  }
};

// Only change code below this line

myStorage.car.inside["glove box"];
var gloveBoxContents = "maps"; // Change this line
Aaron Walton
@AaronFW
May 02 2017 01:09
@khanvuthy88 Is the second loop supposed to say "i > arr.length" should it be "i < arr.length"?
Christopher McCormack
@cmccormack
May 02 2017 01:09
@corritaylor did you change the line that says Change this line?
khanvuthy88
@khanvuthy88
May 02 2017 01:10
@AaronFW , OK I see, I confused, thanks you very much.
CamperBot
@camperbot
May 02 2017 01:10
khanvuthy88 sends brownie points to @aaronfw :sparkles: :thumbsup: :sparkles:
:cookie: 296 | @aaronfw |http://www.freecodecamp.com/aaronfw
Aaron Walton
@AaronFW
May 02 2017 01:10
You are welcome.
Corri Taylor
@corritaylor
May 02 2017 01:10
@cmccormack I guess I’m not clear as to what to change it to...
khanvuthy88
@khanvuthy88
May 02 2017 01:11
@AaronFW and i should change : i=0
Christopher McCormack
@cmccormack
May 02 2017 01:11
@corritaylor what do the instructions ask you to change it to?
Aaron Walton
@AaronFW
May 02 2017 01:12
@khanvuthy88 Good. Did it work now?
@c0d0er2 What do you need help with about that problem?
khanvuthy88
@khanvuthy88
May 02 2017 01:13
@c0d0er2
if(a>0 && b>0){
    return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
  }else{
    return;
  }
Corri Taylor
@corritaylor
May 02 2017 01:14
Thank you @cmccormack! I did that originally but still had the quotes around it so it didn’t work. I second guessed my self and went too deep.
CamperBot
@camperbot
May 02 2017 01:14
corritaylor sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 486 | @cmccormack |http://www.freecodecamp.com/cmccormack
Christopher McCormack
@cmccormack
May 02 2017 01:14
@corritaylor haha I didn’t do anything at all - glad you got it!
c0d0er2
@c0d0er2
May 02 2017 01:15
@khanvuthy88 I tried that just now, and it doesn't seem working.
Corri Taylor
@corritaylor
May 02 2017 01:16
@cmccormack I’m starting to figure out that JavaScript means being meticulous with the directions. A lot of times I tend to over think what's right there in front of my face.
Breyden
@breydens
May 02 2017 01:17
Hey everyone. Any ideas why this isn't logging my JSON object to the console RELIABLY? It seems to work once in a blue moon:
var query;
var url =
  "https://en.wikipedia.org/w/api.php?action=opensearch&format=json&search=";
var results;

$(document).ready(function() {

  // Get the entered string from the search form.
  $("#searchButton").click(function() {
    query = $("#search").val();

    // Get and store the JSON results
    $.getJSON(
      "https://en.wikipedia.org/w/api.php?action=opensearch&format=json&search=" + query + "&callback=?",
      function(apiData) {

        results = apiData;
        console.log(results);

      }
    ); // End getJSON function
  }); // End click function
});
Christopher McCormack
@cmccormack
May 02 2017 01:17
@corritaylor I think that’s the problem for many - the problem descriptions are concise but people are used to long paragraphs spelling things out, so they feel their missing info when the instructions are short
khanvuthy88
@khanvuthy88
May 02 2017 01:19
@c0d0er2 , how about this ?
function abTest(a, b) {
  // Only change code below this line

  if(a<0 || b<0){
    return;
  }else{
    return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
  }
  // Only change code above this line


}

// Change values below to test your code
abTest(2,2);
Corri Taylor
@corritaylor
May 02 2017 01:19
@cmccormack exactly! I just have to take my time...
Christopher McCormack
@cmccormack
May 02 2017 01:19
@breydens I’m not sure if this is it but I remember problems with some APIs if the callback statement wasn’t the first property after the ?
c0d0er2
@c0d0er2
May 02 2017 01:19
@khanvuthy88 Thanks!
CamperBot
@camperbot
May 02 2017 01:19
c0d0er2 sends brownie points to @khanvuthy88 :sparkles: :thumbsup: :sparkles:
:cookie: 44 | @khanvuthy88 |http://www.freecodecamp.com/khanvuthy88
Christopher McCormack
@cmccormack
May 02 2017 01:20
@corritaylor yup keep at it, everyone has a hard time until they don’t :)
barki mustapha
@barkinet
May 02 2017 01:20
chrome \
--headless \ # Runs Chrome in headless mode.
--disable-gpu \ # Temporarily needed for now.
--remote-debugging-port=9222 \
https://www.chromestatus.com # URL to open. Defaults to about:blank.
Rodrigo
@conderodrigo98
May 02 2017 01:20

Hi everybody! Can ypu help me? I'm writing a function to find the length of the longest word in a given string. So far I have this code:

function findLongestWord(str) {
 var words=str.split(/\s/);
 words=words.map(function(w){
    return w.length;
  });
  words=words.sort();
  return words[words.length-1];
}

I don't see any error but the last test ("What if we try a super-long word such as otorhinolaryngology") doesn't work. Any advice??

CamperBot
@camperbot
May 02 2017 01:20
:bulb: to format code use backticks! ``` more info
Christopher McCormack
@cmccormack
May 02 2017 01:22
@conderodrigo98 your map is going to fill the words array with lengths, not indices
Corri Taylor
@corritaylor
May 02 2017 01:23
Oh YAY Loops are next… Yep I’m done for tonight… Goodnight fellow coders, lol.
Breyden
@breydens
May 02 2017 01:23
@cmccormack Interesting. So you're saying to write it like:
$.getJSON(
      "https://en.wikipedia.org/w/api.php?&callback=?action=opensearch&format=json&search=" + query
Stephen James
@sjames1958gm
May 02 2017 01:23
@conderodrigo98 If you want to sort numbers you need to supply a function.
Eduar Tua
@eduartua
May 02 2017 01:23

guys, I don't know what else can do with this tried everything and it does not work:

$(document).ready(function() {
  $("#button").on("click", function(){    
    $.getJSON("http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&callback=", function(json){
      console.log("success");
      $(".quote").html(JSON.stringify(json));
    });
  });
});

Neither prints success

Christopher McCormack
@cmccormack
May 02 2017 01:23
@breydens you can try it but make sure the & is on the other side of the ?
barki mustapha
@barkinet
May 02 2017 01:24

const chrome = require('chrome-remote-interface');

function onPageLoad(Runtime) {
const js = "document.querySelector('title').textContent";

// Evaluate the JS expression in the page.
return Runtime.evaluate({expression: js}).then(result => {
console.log('Title of page: ' + result.result.value);
});
}

launchChrome().then(launcher => {

chrome(protocol => {
// Extract the parts of the DevTools protocol we need for the task.
// See API docs: https://chromedevtools.github.io/debugger-protocol-viewer/
const {Page, Runtime} = protocol;

// First, need to enable the domains we're going to use.
Promise.all([
  Page.enable(),
  Runtime.enable()
]).then(() => {
  Page.navigate({url: 'https://www.chromestatus.com/'});

  // Wait for window.onload before doing stuff.
  Page.loadEventFired(() => {
    onPageLoad(Runtime).then(() => {
      protocol.close();
      launcher.kill(); // Kill Chrome.
    });
  });

});

}).on('error', err => {
throw Error('Cannot connect to Chrome:' + err);
});

});

Christopher McCormack
@cmccormack
May 02 2017 01:24
@eduartua are you getting ”success”?
Rodrigo
@conderodrigo98
May 02 2017 01:25
@sjames1958gm That was the problem!! Thanks for the help!
CamperBot
@camperbot
May 02 2017 01:25
conderodrigo98 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7075 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
May 02 2017 01:25
@breydens You start query parameters with ? and separate them with & (the ? in calllback=? is not counted as a separator,)
@conderodrigo98 :+1:
Breyden
@breydens
May 02 2017 01:26
@cmccormack Alright, so that did give me an object back, but I'm still having the same problem as before: it doesn't work every time I click search. Only sporadically
Christopher McCormack
@cmccormack
May 02 2017 01:27
@breydens are you using the same query everytime? Your browser may not print duplicates to console
do you have a codeine?
Eduar Tua
@eduartua
May 02 2017 01:27
@cmccormack No I am not
Breyden
@breydens
May 02 2017 01:28
@cmccormack I'm switching up my searches each time. Here's the pen, if you're curious: http://codepen.io/breydens/pen/JNEgyE
I should clarify that I'm just trying to log to console at the moment, not add HTML elements.
Christopher McCormack
@cmccormack
May 02 2017 01:29
@breydens did you save your pen?
Breyden
@breydens
May 02 2017 01:29
@cmccormack Just did.
Christopher McCormack
@cmccormack
May 02 2017 01:30
@breydens i’m not seeing how you ever get a response, you need to preventDefault your form submisson so it doesn’t reload each time
@breydens yup that’s all you should need, worked after I added that
$('form').submit(function(e){ e.preventDefault(); })
Davis Jaunbruns
@davis4acca
May 02 2017 01:33
@cmccormack Hey Chris, thanks for response, how can i pass that as a callback in the code i wrote?
CamperBot
@camperbot
May 02 2017 01:33
davis4acca sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 487 | @cmccormack |http://www.freecodecamp.com/cmccormack
Eduar Tua
@eduartua
May 02 2017 01:34
I don't wanna go bed with a bug in mind --> HELP
Breyden
@breydens
May 02 2017 01:34
thanks @cmccormack That's it. It did the trick. Thank you so much!
CamperBot
@camperbot
May 02 2017 01:34
breydens sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 488 | @cmccormack |http://www.freecodecamp.com/cmccormack
Christopher McCormack
@cmccormack
May 02 2017 01:34
@davis4acca pass createUserList? just add the name to the callback portion of your success: method. Make sure you add a parameter to your createUserList as well so you can work off that
@breydens np
If I remember correctly it would just look like success: createUserList, @davis4acca
barki mustapha
@barkinet
May 02 2017 01:45

var closureBuilder = require('closure-builder');
var glob = closureBuilder.globSupport();

closureBuilder.build({
name: 'goog.namespace',
srcs: glob([
'src//*.js',
'soy/
/*.soy'
]),
deps: [...],
out: 'genfiles/whatever.js'
});

Pagnito
@Pagnito
May 02 2017 01:50
curse you recursion, i still dont get it!!
Christopher McCormack
@cmccormack
May 02 2017 01:51
did you write it out on paper? :)
Pagnito
@Pagnito
May 02 2017 01:55
@cmccormack yea i tried but i didnt even know how to express it visually, i get certain cases of recursion
but i dont get when they concat or add the call
cuz i dont see how recalling the function adds the numbers, cuz the function itself doesnt have adding unless args.length==2
Christopher McCormack
@cmccormack
May 02 2017 01:56
@Pagnito just follow each call and note the state of the variables as you go along
gerome0123
@gerome0123
May 02 2017 01:57
how to push an array with the index??
Christopher McCormack
@cmccormack
May 02 2017 01:57
@Pagnito I can’t see the code you’re referring to
Pagnito
@Pagnito
May 02 2017 01:58
hold on
Christopher McCormack
@cmccormack
May 02 2017 01:58
@gerome0123 push adds an item to the end of an array
gerome0123
@gerome0123
May 02 2017 01:58
@cmccormack can give an example T_T
myarray = []
Pagnito
@Pagnito
May 02 2017 01:59
function flatten(ary) {
    var ret = [];
    for(var i = 0; i < ary.length; i++) {
        if(Array.isArray(ary[i])) {
            ret = ret.concat(flatten(ary[i]));
        } else {
            ret.push(ary[i]);
        }
    }
    return ret;
}

flatten([[[[[0]], [1]], [[[2], [3]]], [[4], [5]]]]) // [0, 1, 2, 3, 4, 5]
i cant understand how concating the call itself concats anything
gerome0123
@gerome0123
May 02 2017 01:59
myarray.push(id: myindex)
khanvuthy88
@khanvuthy88
May 02 2017 01:59

Dear member here. Please help me with this one.
Modify function multiplyAll so that it multiplies the product variable by each number in the sub-arrays of arr

function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line

  // Only change code above this line
  return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);

I don't understand this, my English to low.

Will
@Will-is-Coding
May 02 2017 01:59
Christopher McCormack
@cmccormack
May 02 2017 02:00
@gerome0123
> var a = [1,2,3,4]
> a.push(5)
> a
[ 1, 2, 3, 4, 5 ]
> a.push(6)
> a
[ 1, 2, 3, 4, 5, 6 ]
Christopher McCormack
@cmccormack
May 02 2017 02:01
@Pagnito when flatten(ary[i]) finally returns, it gets concatenated to ret using ret.concat(/*return value*/)
gerome0123
@gerome0123
May 02 2017 02:02
how to detect if i delete 4? then i have the unique id?
Pagnito
@Pagnito
May 02 2017 02:02
@cmccormack so is the return value the first array in the arg?
Will
@Will-is-Coding
May 02 2017 02:02
@Pagnito Think of it this way, you have 2 cases. Either Array.isArray(ary[i]) the item is an array, or it is not. If it is not an array, as in 0 or 1 (aka an integer), then push it onto the empty array and return that. You then move forward. Let me try to type out the steps
Christopher McCormack
@cmccormack
May 02 2017 02:02
@gerome0123 not really sure what you’re asking - push() simply adds an item to the end of an array - what are you trying to accomplish?
gerome0123
@gerome0123
May 02 2017 02:03
@cmccormack im trying to accomplish here is my i array have a unique id base on there index even i delete it
Christopher McCormack
@cmccormack
May 02 2017 02:04
@gerome0123 that didn't really tell us what you’re trying to accomplish
Will
@Will-is-Coding
May 02 2017 02:04
The main thing is there is always a "base case" essentially, which is what you will first return. Your recursion hits an end point, like the end of a branch, and moves back out until extending down another branch. @Pagnito The base case here is that the item is NOT an array, and in this case it is an integer, and it will be added to an empty array, then returned. Each time these one arrays [0] [1] etc. is returned, you concat them onto the inital ret
gerome0123
@gerome0123
May 02 2017 02:05
im using mdDataTable by iamist and there is a pitfull
Vinicius Otacilio
@Karumba15
May 02 2017 02:05
Hey guys, someone can help me ? i dont understanding the Finding a Remainder in JavaScript lesson
gerome0123
@gerome0123
May 02 2017 02:05
the table is detecting id not a index
in my json
barki mustapha
@barkinet
May 02 2017 02:06

Assignment:

number = 42
opposite = true

Conditions:

number = -42 if opposite

Functions:

square = (x) -> x * x

Arrays:

list = [1, 2, 3, 4, 5]

Objects:

math =
root: Math.sqrt
square: square
cube: (x) -> x * square x

Splats:

race = (winner, runners...) ->
print winner, runners

Existence:

alert "I knew it!" if elvis?

Array comprehensions:

cubes = (math.cube num for num in list)
var cubes, list, math, num, number, opposite, race, square,
slice = [].slice;

number = 42;

opposite = true;

if (opposite) {
number = -42;
}

square = function(x) {
return x * x;
};

list = [1, 2, 3, 4, 5];

math = {
root: Math.sqrt,
square: square,
cube: function(x) {
return x * square(x);
}
};

race = function() {
var runners, winner;
winner = arguments[0], runners = 2 <= arguments.length ? slice.call(arguments, 1) : [];
return print(winner, runners);
};

if (typeof elvis !== "undefined" && elvis !== null) {
alert("I knew it!");
}

cubes = (function() {
var i, len, results;
results = [];
for (i = 0, len = list.length; i < len; i++) {
num = list[i];
results.push(math.cube(num));
}
return results;
})();

gerome0123
@gerome0123
May 02 2017 02:06
i need an array that can push an index to the id so i can detect my array even if i delete one of my id
Pagnito
@Pagnito
May 02 2017 02:08
@Will-is-Coding yea i get the base case part and how it works, but i dont get the mechanics of concating the call, how does that return a value? is the value being returned the first array type in arg array. and by concating it to ret doesnt that only strip one layer of array brackets, so if it keeps calling itself doesnt it concat another ary[i], what happens with the last multilayered array that got concatted
Christopher McCormack
@cmccormack
May 02 2017 02:09
@Karumba15 what is your issue?
Vinicius Otacilio
@Karumba15
May 02 2017 02:09
@cmccormack how i should find the remainder? var remainder; 11 % 3
?
i really not getting how to put this in the code
but i understand the theory part
Christopher McCormack
@cmccormack
May 02 2017 02:10
@Karumba15 try var remainder = 11 % 3;
@Karumba15 11 % 3 is an expression, and the result of that expression needs to be assigned to a variable using =
Vinicius Otacilio
@Karumba15
May 02 2017 02:11
@cmccormack hmm thats worked, thanks dude
CamperBot
@camperbot
May 02 2017 02:11
karumba15 sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 489 | @cmccormack |http://www.freecodecamp.com/cmccormack
FlashHero
@FlashHero
May 02 2017 02:11

function translatePigLatin(str) {
  var current=[];
  var result=[];
  var arr=str.split('');
  var vowels=['a','e','i','o','u'];
  for(var i=0;i<arr.length;i++){
    if(vowels.includes(arr[0])){
      return str.join('')+'way';
    }
    else if(!vowels.includes(arr[i])){
       current.push(arr[i]);

    }else if(vowels.includes(arr[i])){
      var firstvowel=str.indexOf(arr[i]);
      var sliceup=arr.slice(firstvowel);
      result.push(sliceup.join(''));
    }
  }
  return result+current+'ay';
}

translatePigLatin("consonant");
I need help
Will
@Will-is-Coding
May 02 2017 02:11
@Pagnito The concat doesn't happen just at once. Inside the concat the function is called, and thus is waiting for a returned value - but the final value to concat, aka [0, 1, 2, 3] won't be sent till the very last step. After the last multlayered array gets concated into the base one, it returns it to whoever called the flatten function to begin with
Pagnito
@Pagnito
May 02 2017 02:12
@Will-is-Coding yea im lost lol
JM Meneses
@jmdmxx
May 02 2017 02:12

// Setup
var a;
var b = 7;

// Only change code below this line
a = 7;
a = b;

Do not change code above the line?
help
Jennifer Shen
@Jshen18
May 02 2017 02:13
Could someone explain the "Stand in Line" lesson?
Pagnito
@Pagnito
May 02 2017 02:13
im looking at the console.log and looking at ret = [] on every call, and on the first call it alrdy has 0 on the third, it has one and so on
Will
@Will-is-Coding
May 02 2017 02:14
@Pagnito Lol sorry, it is very hard to describe. Ill type out the function in steps and PM them but I gtg now.
Pagnito
@Pagnito
May 02 2017 02:14
k thanks @Will-is-Coding
CamperBot
@camperbot
May 02 2017 02:14
pagnito sends brownie points to @will-is-coding :sparkles: :thumbsup: :sparkles:
:cookie: 484 | @will-is-coding |http://www.freecodecamp.com/will-is-coding
Christopher McCormack
@cmccormack
May 02 2017 02:15
@jmdmxx what are the instructions asking you to do?
JM Meneses
@jmdmxx
May 02 2017 02:16
@cmccormack Do not change code above the line
a should have a value of 7
b should have a value of 7
a should be assigned to b with =
Christopher McCormack
@cmccormack
May 02 2017 02:16
@FlashHero are you turning current back into a string anywhere?
JM Meneses
@jmdmxx
May 02 2017 02:17

@cmccormack
I tried this too: |

// Setup
var a;
var b = 7;

// Only change code below this line
a = 7;
b = 7;
a = b;

FlashHero
@FlashHero
May 02 2017 02:17
@cmccormack yes i just did thanks but the result i get is not what is expected though can you help me with that i don't know what's wrong
CamperBot
@camperbot
May 02 2017 02:17
flashhero sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 490 | @cmccormack |http://www.freecodecamp.com/cmccormack
Joseph
@revisualize
May 02 2017 02:18
Hello.
Christopher McCormack
@cmccormack
May 02 2017 02:18
@jmdmxx a should be assigned to b, not the other way. Assignment works from right to left, so var cat = ‘felix’; you are assigning the string ‘felix’ to the variable cat
Joseph
@revisualize
May 02 2017 02:18
@jmdmxx Variables hold values.
Christopher McCormack
@cmccormack
May 02 2017 02:18
@FlashHero I’m still looking through your logic
FlashHero
@FlashHero
May 02 2017 02:19
ok
Joseph
@revisualize
May 02 2017 02:19
@jmdmxx
How do you assign the value of 7 to a variable num? ... var num = 7;
Now if you want you can use a variable to store values.
Like in mathmatics. num + 3 = 10 What is the value of num?
var x = num + 3; ... That outputs 10
So, you can do several things with variables. But, you need to understand that variables hold values and variables can be used with other variables.
So, how do you assign the value of 5 to a variable x? ... x = 5; (Which is also overwriting the previous value of 10 from above.
How do you assign the value of x to a variable y?
Look at the way things are written. var y = x;
How do you assign the value of 42 to a variable answer? ... What is the answer?
Variables hold values. Just understand that.
Alexx Martínez
@AlexxMart
May 02 2017 02:20
I have an issue with the lesson "Nesting For Loops". The result says "1". My code
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line

  for (var i = 0; i < arr.length; i++) {
    for (var j = 0; j < arr[1].length; j++) {
      for (var k = 0; k < arr[2].length; k++) 

      console.log(arr[i][j][k]);
    }
  }

  // Only change code above this line
  return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
Christopher McCormack
@cmccormack
May 02 2017 02:21
@FlashHero I’m not 100% sure your else if statements are doing what you want, you may want to walk slowly through an example while writing your results
@revisualize hello
Joseph
@revisualize
May 02 2017 02:21
@AlexxMart because, you're not modifying product.
Vinicius Otacilio
@Karumba15
May 02 2017 02:21
Someone can help me in the convert celcius to fahrenheit challenge
this is how i do ?
convertToF(30); var fahrenheit = 30*9/5+32;
Joseph
@revisualize
May 02 2017 02:22
@AlexxMart console.log(arr[i][j][k]); isn't modifying product.
caleb95hunter
@caleb95hunter
May 02 2017 02:22
So, what exactly do I need to do in the Stand In Line challenge?
Christopher McCormack
@cmccormack
May 02 2017 02:22
@Karumba15 your conversion formula has a parameter called celsius, correct? You should be using that variable against the formula then assigning it to fahrenheit
Joseph
@revisualize
May 02 2017 02:22

@Karumba15 There is the function declaration of function convertToF(celsius) { .. You have a function name of convertToF and a parameter of celsius
Parameters are used just like variables. So, inside of the function you can use celsius JUST like any other variable.
If I have this code:

function addThree (num) {
    var result;
    result = num + 3;
    return result;
}

So, when we make the function call of:

addThree(10);

You're calling the function addThree You're also passing a value 10 as an argument.
In the function declaration of function addThree (num) { You see that there is a parameter defined of num
When we do addThree(10) then the value of the parameter num is passed the argument value of ... 10
Then if you follow the code through.. result = num + 3; ... and we know the value of num is 10.
Therefore, if we follow through the function we end up with ... result = 10 + 3; then result = 13; then we return the result.
...
If you then make another function call..

addThree(39);

You can use the same function to follow the operation:
When we do addThree(39) then the value of the parameter num is passed the argument value of ... 39
Then if you follow the code through.. result = num + 3; ... and we know the value of num is now 39.
Therefore, if we follow through the function we end up with ... result = 39 + 3; then result = 42; then we return the result.

The algorithm to convert from Celsius to Fahrenheit is the temperature in Celsius times 9/5, plus 32

Vinicius Otacilio
@Karumba15
May 02 2017 02:23
i think i dont understand but i will try again
JM Meneses
@jmdmxx
May 02 2017 02:23
@cmccormack @revisualize thanks guys. will be back later. ciao!
CamperBot
@camperbot
May 02 2017 02:23
jmdmxx sends brownie points to @cmccormack and @revisualize :sparkles: :thumbsup: :sparkles:
:cookie: 491 | @cmccormack |http://www.freecodecamp.com/cmccormack
:star2: 3867 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
May 02 2017 02:24
@Karumba15 If you don't understand How can I help?
Vinicius Otacilio
@Karumba15
May 02 2017 02:25
@revisualize i trying to undertand what you say ... i dont know if i understand properly, i will try make the code again and brb
Alexx Martínez
@AlexxMart
May 02 2017 02:26
@revisualize I still don't get how to modify product
Joseph
@revisualize
May 02 2017 02:28
@AlexxMart If I declare and initialize a variable var num = 20;. How do I change the value of the variable num to 42?
Vinicius Otacilio
@Karumba15
May 02 2017 02:29

function convertToF(celsius) {
var fahrenheit=9/5+32;
// Only change code below this line

// Only change code above this line
return fahrenheit;
}

// Change the inputs below to test your code
convertToF(0); var fahrenheit=9/5+32;

this is right?
Joseph
@revisualize
May 02 2017 02:29
@Karumba15 That is not correct.
Vinicius Otacilio
@Karumba15
May 02 2017 02:30
@revisualize i can´t change the fahrenheit function at the first line?
Joseph
@revisualize
May 02 2017 02:31
@Karumba15 Look, If I have a function declaration of: function addThree (num) { } and I make a function call of addThree(10); ... What is the value of num inside of the function?
Dbakk
@Dbakk
May 02 2017 02:31
question on Local Scope and Functions
Vinicius Otacilio
@Karumba15
May 02 2017 02:31
@revisualize 10?
Joseph
@revisualize
May 02 2017 02:31
@Karumba15 Correct.
caleb95hunter
@caleb95hunter
May 02 2017 02:31
@Dbakk Whatcha got?
Dbakk
@Dbakk
May 02 2017 02:31
function myLocalScope() {
'use strict';
var loc = "myVar";
console.log(myVar);
}
myLocalScope();
Joseph
@revisualize
May 02 2017 02:31
@Karumba15 If I have a function declaration of: function addThree (num) { } and I make a function call of addThree(39); ... What is the value of num inside of the function?
Vinicius Otacilio
@Karumba15
May 02 2017 02:32
@revisualize 39
Joseph
@revisualize
May 02 2017 02:32
@Karumba15 If I have a function declaration of: function addThree (num) { } and I make a function call of addThree(1000); ... What is the value of num inside of the function?
caleb95hunter
@caleb95hunter
May 02 2017 02:32
@Dbakk What's your question?
Vinicius Otacilio
@Karumba15
May 02 2017 02:32
@revisualize 1000
@revisualize i think i undertand now
Dbakk
@Dbakk
May 02 2017 02:32
@caleb95hunter its not giving me a valid input response on my code
Joseph
@revisualize
May 02 2017 02:33
@Karumba15 If I have a function declaration of function convertToF(celsius) { } and I make a function call of convertToF(2) ... What is the value of celsius inside of the function?
Vinicius Otacilio
@Karumba15
May 02 2017 02:33
@revisualize 2
Dbakk
@Dbakk
May 02 2017 02:33
Im not sure what I am doing wrong
Joseph
@revisualize
May 02 2017 02:33
@Karumba15 The algorithm to convert from Celsius to Fahrenheit is the temperature in Celsius times 9/5, plus 32
caleb95hunter
@caleb95hunter
May 02 2017 02:34
So, have you declared the local variable inside the function, myVar?
Vinicius Otacilio
@Karumba15
May 02 2017 02:34
@revisualize so i make function convertToF(celsius) { var farenheit=9/5 + 32 }
Joseph
@revisualize
May 02 2017 02:34
@Karumba15 No. The algorithm to convert from Celsius to Fahrenheit is the temperature in Celsius times 9/5, plus 32
@Karumba15 Is var farenheit=9/5 + 32 the same as Celsius times 9/5, plus 32 ?
FlashHero
@FlashHero
May 02 2017 02:35
@revisualize can you help me
Dbakk
@Dbakk
May 02 2017 02:35
@caleb95hunter I thought thats what this was " var loc = "myVar"; "
Joseph
@revisualize
May 02 2017 02:35
@Karumba15 If not. What's missing?
Vinicius Otacilio
@Karumba15
May 02 2017 02:35
@revisualize no... so how i call the celcius inside my variable?
Joseph
@revisualize
May 02 2017 02:36
@Karumba15 You use the parameter just like a variable.
Mario A. Carlos
@MarioC3
May 02 2017 02:36
Hello Guys!
Joseph
@revisualize
May 02 2017 02:36
@Karumba15 The parameter is declared during the function instantiation (creation)
Mario A. Carlos
@MarioC3
May 02 2017 02:36
Need some help with queues in Javascript!
caleb95hunter
@caleb95hunter
May 02 2017 02:36
@Dbakk Variables that are declared inside the function block are local variables automatically... So you don't have to declare it as "var loc" ... The variable is simply.... var myVar;
Vinicius Otacilio
@Karumba15
May 02 2017 02:36
@revisualize hmm now i understand... thanks man
CamperBot
@camperbot
May 02 2017 02:36
karumba15 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3868 | @revisualize |http://www.freecodecamp.com/revisualize
Mario A. Carlos
@MarioC3
May 02 2017 02:37
It's stand in line problem of FCC
Joseph
@revisualize
May 02 2017 02:37
@MarioC3 What is your function?
@FlashHero What is your problem? Have you ran your problem through www.pythontutor.com/javascript.html ?
Mario A. Carlos
@MarioC3
May 02 2017 02:38
these are the instructions:
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 02 2017 02:38
@MarioC3 Okay. What is your function?
Mario A. Carlos
@MarioC3
May 02 2017 02:38
This is what I did:
Pagnito
@Pagnito
May 02 2017 02:38
i think im starting to understand recursion, i can def see what u meant by writing down on a piece of paper lol, a video im watching drew it really good. it was nothing like i was thinking lol
@cmccormack
Mario A. Carlos
@MarioC3
May 02 2017 02:39

'function nextInLine(arr, item) {
// Your code here
arr.push(item);
arr.shift(arr[0]);
return 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, 4)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
'

Joseph
@revisualize
May 02 2017 02:39
@MarioC3 .shift() doesn't take an argument.
Dbakk
@Dbakk
May 02 2017 02:39
okay, so I got it, I guess the example is what threw me off
thanks @caleb95hunter
CamperBot
@camperbot
May 02 2017 02:39
dbakk sends brownie points to @caleb95hunter :sparkles: :thumbsup: :sparkles:
:cookie: 167 | @caleb95hunter |http://www.freecodecamp.com/caleb95hunter
Joseph
@revisualize
May 02 2017 02:40
@MarioC3 So, you're return item; what are you supposed to be returning?
caleb95hunter
@caleb95hunter
May 02 2017 02:40
@Dbakk No problem! Glad you got through it!
Christopher McCormack
@cmccormack
May 02 2017 02:41
@Pagnito haha yeah it really isn’t. The branch analogy that was used earlier was pretty on point though - you’re going up and down different branches many times based on some current value until all calls to the recursive function have completed and it all settles back down to the original call
Mario A. Carlos
@MarioC3
May 02 2017 02:41
function nextInLine(arr, item) {
  // Your code here
  arr.push(item);
  arr.shift(arr[0]);
  return 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, 4)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Damien
@DubbDevs
May 02 2017 02:41
currently on accessing Objects properties with variables and whoa seems confusing and unnecessary. I understand how to access with the dot operator and bracket notation... but using the variable seems easy but seeing it is...messy.
Mario A. Carlos
@MarioC3
May 02 2017 02:41
Yes! I know how to post code now! lol
Joseph
@revisualize
May 02 2017 02:41
@MarioC3 .shift() doesn't take an argument.
@MarioC3 So, you're return item; what are you supposed to be returning?
khanvuthy88
@khanvuthy88
May 02 2017 02:42

@cmccormack , Please kindly help me with this one :

function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line

  // Only change code above this line
  return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);

Modify function multiplyAll so that it multiplies the product variable by each number in the sub-arrays of arr. I don't understand.

Mario A. Carlos
@MarioC3
May 02 2017 02:43
@revisualize what does shift does?
do*
Joseph
@revisualize
May 02 2017 02:43
@MarioC3 That's a good question. Can you tell me what .shift() does?
Mario A. Carlos
@MarioC3
May 02 2017 02:44
So .shift() takes the removes the first element (0)
Joseph
@revisualize
May 02 2017 02:44
@MarioC3 What else does it do?
Christopher McCormack
@cmccormack
May 02 2017 02:45
@khanvuthy88 it basically wants you to make two loops, one to iterate over the sequence of arrays, and another loop nested inside the first loop that iterates over each value inside an array. Within that second loop, you want to make the product value equal to product * the current value in the array
Mario A. Carlos
@MarioC3
May 02 2017 02:45
it re-arranges all the values one index down and returns the taken value
right?
Joseph
@revisualize
May 02 2017 02:45
@MarioC3 I guess that's one way to explain it.
@MarioC3 The shift() method removes the first element from an array and returns that element.
Michael Grienauer
@mgrienauer
May 02 2017 02:45
im trying to make a tictactoe game using jquery and bootstrap, but I dont want to use codepen anymore I want to do it locally on my pc using atom editor...but Im totally lost as to how I would link to jquery and bootstrap stylesheets
do i need to download them, or can I link to a CDN
Christopher McCormack
@cmccormack
May 02 2017 02:46
@mike93og93 you can use the CDN, just put the links in the <head></head> section of your html
Joseph
@revisualize
May 02 2017 02:46
@mike93og93 Link to the cdn.
Michael Grienauer
@mgrienauer
May 02 2017 02:46
<body>
        <h1 class="text-center">Tic Tac Toe</h1>  
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
        <link href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
        <link rel="stylesheet" href="tictac.css" media="screen" charset="utf-8">
        <script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
        <script src="tictac.js" charset="utf-8"></script>


        <div class="container-fluid gameboard">

        </div>  
    </body>
I have that in my body but when I preview anything I try to make it doesnt look like bootstrap or jquery laoded
Christopher McCormack
@cmccormack
May 02 2017 02:47
@mike93og93 it goes in the head
Joseph
@revisualize
May 02 2017 02:47
@mike93og93 That isn't how you link to the CDN
Michael Grienauer
@mgrienauer
May 02 2017 02:47
@revisualize how would I link to the CDN?
ive been looking online but cant find anything about it somehow
Christopher McCormack
@cmccormack
May 02 2017 02:47
if you google Bootstrap CDN, it has all the options if you click the down arrow
Joseph
@revisualize
May 02 2017 02:48
@mike93og93 All of the stuff goes in the <head></head>
@mike93og93 It tells you on this page: https://getbootstrap.com/getting-started/
. 4. Basic HTML template
caleb95hunter
@caleb95hunter
May 02 2017 02:49
This Stand In Line challenge is throwing me for a loop.
Christopher McCormack
@cmccormack
May 02 2017 02:50
@revisualize that one’s a bit out of date and I think it’s for local copy, http://getbootstrap.com/getting-started/
Joseph
@revisualize
May 02 2017 02:50
@caleb95hunter What is the state of your function.
@cmccormack That's what google gave me.
Michael Grienauer
@mgrienauer
May 02 2017 02:50
@revisualize @cmccormack thanks guys ill see if i can get it working
CamperBot
@camperbot
May 02 2017 02:50
mike93og93 sends brownie points to @revisualize and @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 493 | @cmccormack |http://www.freecodecamp.com/cmccormack
:star2: 3869 | @revisualize |http://www.freecodecamp.com/revisualize
Christopher McCormack
@cmccormack
May 02 2017 02:50
@mike93og93 gl
caleb95hunter
@caleb95hunter
May 02 2017 02:50

@revisualize function nextInLine(arr, item) {
// Your code here
arr.push(item);
arr.shift(arr);
return 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));

Christopher McCormack
@cmccormack
May 02 2017 02:50
@mike93og93 one note - if you’re going to use Bootstrap JS, make sure you load jquery above your bootstrap js
Joseph
@revisualize
May 02 2017 02:51
@caleb95hunter .shift() doesn't take an argument.
jhobotuck
@jhobotuck
May 02 2017 02:51

So I have gotten this far on "Seek and Destory"

```

khanvuthy88
@khanvuthy88
May 02 2017 02:51
@cmccormack , that great, it's work now. here is my code :
for(var i=0;i<arr.length; i++){
    for(var j=0;j<arr[i].length;j++){
      product= product*arr[i][j];
    }
  }
  return product;
Joseph
@revisualize
May 02 2017 02:51
@caleb95hunter You're doing return item; ... What are you supposed to be returning?
jhobotuck
@jhobotuck
May 02 2017 02:51
function destroyer(arr) {

  var resultArray = [];

  resultArray = arr.filter(function(val){

    for (var i = 0; i < arr.length - 1; i++) {
      if (val === arguments[i + 1]) {
        return true;
      } else {
        return false;
      }
    }


  });

  return resultArray;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Christopher McCormack
@cmccormack
May 02 2017 02:51
@khanvuthy88 wow that was really fast, nice job
Mario A. Carlos
@MarioC3
May 02 2017 02:52
@revisualize should I be using .pop() then?
Joseph
@revisualize
May 02 2017 02:52
@MarioC3 Nope.
khanvuthy88
@khanvuthy88
May 02 2017 02:52
@revisualize , thanks for your document.
CamperBot
@camperbot
May 02 2017 02:52
khanvuthy88 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3870 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
May 02 2017 02:52
@MarioC3 What does .pop() do?
Michael Grienauer
@mgrienauer
May 02 2017 02:52
@cmccormack will do
khanvuthy88
@khanvuthy88
May 02 2017 02:52
@cmccormack , it's work.
Joseph
@revisualize
May 02 2017 02:52
@khanvuthy88 Did that help? Any suggestions for improvement?
caleb95hunter
@caleb95hunter
May 02 2017 02:52
@revisualize To be honest, I don't even know... That 'return item;' line is an arbitrary code for that challenge... it has commented out to the side to change it, but I don't know how, or what, or why, or where, or when.
Mario A. Carlos
@MarioC3
May 02 2017 02:53
pops a value off of the end of the array
khanvuthy88
@khanvuthy88
May 02 2017 02:53
@cmccormack , it's work. Thanks you very m uch
CamperBot
@camperbot
May 02 2017 02:53
khanvuthy88 sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 494 | @cmccormack |http://www.freecodecamp.com/cmccormack
Mario A. Carlos
@MarioC3
May 02 2017 02:53
oh the end of the array!!!
Joseph
@revisualize
May 02 2017 02:53
@caleb95hunter What do the instructions state you should be returning?
Dazaev
@dazaevvc
May 02 2017 02:53
heyaaa

var Car = function(wheels, seats, engines) {
//Change this constructor
this.wheels = 4;
this.seats = 5;
this.engines = 1;
};

//Try it out here
var myCar = new Car(3,1,420);

Michael Grienauer
@mgrienauer
May 02 2017 02:53
@cmccormack just to be clear...i dont have to download bootstrap right? i can just link to a cdn and it should work?
Dazaev
@dazaevvc
May 02 2017 02:53
can anyone find whats wrong?
Christopher McCormack
@cmccormack
May 02 2017 02:53
@mike93og93 not unless you want to
@mike93og93 yup linking should work perfectly fine provided your internet connection is active at the time :D
caleb95hunter
@caleb95hunter
May 02 2017 02:54
Should be returning that element that was removed... So essentially it should be returning the shift value?
FlashHero
@FlashHero
May 02 2017 02:54

function translatePigLatin(str) {
  var consonant =[];
  var result=[];
  var arr=str.split('');
  var vowels=['a','e','i','o','u'];
  for(var i=0;i<arr.length;i++){
    if(vowels.includes(arr[0])){
      return str+'way';
    }else if(vowels.includes(arr[i])){
      var firstvowel=str.indexOf(arr[i]);
      var sliceup=arr.slice(firstvowel);
      result.push(sliceup.join(''));

    }else if(!vowels.includes(arr[i])){
        consonant.push(arr[i]);

    }
  }
  return result+consonant.join('')+'ay';
}

translatePigLatin("consonant");
@revisualize it seems that the code still executes even after an vowel is found and the logic is that when vowel is found then add consonant and return
Joseph
@revisualize
May 02 2017 02:54
@caleb95hunter Yes.
khanvuthy88
@khanvuthy88
May 02 2017 02:54
@revisualize , actually i do not understand with they want. after @cmccormack explained me. I just follow his advice.
Joseph
@revisualize
May 02 2017 02:55
@FlashHero Why not break; if a vowel is found?
Mario A. Carlos
@MarioC3
May 02 2017 02:55
@revisualize I'm still lost
:(
So, why can't I use .shift()
caleb95hunter
@caleb95hunter
May 02 2017 02:55
@revisualize Okay, sooooo I should assign the .shift value to a variable and return the variable?
Joseph
@revisualize
May 02 2017 02:55
@MarioC3 YOU DO!
FlashHero
@FlashHero
May 02 2017 02:55
@revisualize yay finally I solved it thank you so much for that website its so helpful
CamperBot
@camperbot
May 02 2017 02:55
flashhero sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3871 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
May 02 2017 02:56
@caleb95hunter No. Just return the shift process.

@MarioC3 Question:

function getName() { return "Happy Feet"; }
var name = getName();
console.log(name);

What do you think is output to the console when you log the variable name?
Why do you think that is?

Christopher McCormack
@cmccormack
May 02 2017 02:56
@mike93og93 best practice is to use the following code as your template, and add stuff like your Bootstrap and jquery and fontawesome as necessary in the head portion:
<!DOCTYPE html>
<html>
<head>
    <title>Page Title</title>
    /* External libraries go here */
</head>
<body>
    /*  Code goes here */
</body>
</html>
FlashHero
@FlashHero
May 02 2017 02:56
@revisualize what's the difference between return and break though
Christopher McCormack
@cmccormack
May 02 2017 02:56
@cmccormack Codepen doesn’t require you add most of that
Joseph
@revisualize
May 02 2017 02:56
@caleb95hunter
function returnThing() {
   var thisThing = "String Thing";
   var thatThing = thisThing;
   var hisThing = thatThing;
   var herThing = hisThing;
   return herThing;
}
Mario A. Carlos
@MarioC3
May 02 2017 02:57
@revisualize 'Happy feet'
Joseph
@revisualize
May 02 2017 02:57
@caleb95hunter vs.
function returnThing() {
    return "String Thing";
}
Mario A. Carlos
@MarioC3
May 02 2017 02:57
right?
Joseph
@revisualize
May 02 2017 02:57
@MarioC3 Why?
caleb95hunter
@caleb95hunter
May 02 2017 02:57

'''
function nextInLine(arr, item) {
// Your code here
arr.push(item);
arr.shift();
return arr.shift; // Change this line
}

'''

CamperBot
@camperbot
May 02 2017 02:57
:bulb: to format code use backticks! ``` more info
Joseph
@revisualize
May 02 2017 02:57
@caleb95hunter Don't .shift() twice.
Mario A. Carlos
@MarioC3
May 02 2017 02:58
I understand that... the varianble name is equals to the function get name. And that function returns 'Happy Feet'
Joseph
@revisualize
May 02 2017 02:58
@MarioC3 The shift() method removes the first element from an array and returns that element.
caleb95hunter
@caleb95hunter
May 02 2017 02:59
@revisualize Got it. Thanks so much!
CamperBot
@camperbot
May 02 2017 02:59
caleb95hunter sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3872 | @revisualize |http://www.freecodecamp.com/revisualize
Mario A. Carlos
@MarioC3
May 02 2017 02:59
I'm just confused....
You said a couple lines above that shift does not take an argument
@MarioC3 .shift() doesn't take an argument.
Joseph
@revisualize
May 02 2017 03:00
@MarioC3 Correct. arr.shift() doesn't take an argument.
Mauro
@mauronml
May 02 2017 03:00
I’d like some help with this challenge (if anyone has a chance):
https://www.freecodecamp.com/challenges/profile-lookup
Mario A. Carlos
@MarioC3
May 02 2017 03:00
why not?
Christopher McCormack
@cmccormack
May 02 2017 03:01
@MarioC3 maybe this will help:
> var a = [12,24,36]
undefined
> a.shift()
12
> a
[ 24, 36 ]
Joseph
@revisualize
May 02 2017 03:01
@MarioC3 Doing: arr.shift(arr[0]) is incorrect because .shift() doesn't take an argument. It should just be arr.shift()
Mario A. Carlos
@MarioC3
May 02 2017 03:01
Shouldn't be taking the first argument of the array?
Joseph
@revisualize
May 02 2017 03:01
@MarioC3 The shift() method removes the first element from an array and returns that element.
Mario A. Carlos
@MarioC3
May 02 2017 03:01
ok...
Joseph
@revisualize
May 02 2017 03:01
There is no reason to supply an argument.
It ALWAYS removes the first element from the array.
Mario A. Carlos
@MarioC3
May 02 2017 03:01
unction nextInLine(arr, item) {
  // Your code here
  arr.push(item);
  arr.shift();
  return 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, 4)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Joseph
@revisualize
May 02 2017 03:02
No more. No less.
@MarioC3 Okay. return item; What should you be returning?
Mario A. Carlos
@MarioC3
May 02 2017 03:02
so here, 'arr.shift()' is correct? because I don't need to specify what element needs to be taken away
Joseph
@revisualize
May 02 2017 03:02
@MarioC3 That arr.shift() is correctly written.
@MarioC3 Because it will only remove the first element.
Mario A. Carlos
@MarioC3
May 02 2017 03:03
cool, so do i need to return arr.shift();
?
Joseph
@revisualize
May 02 2017 03:03
Sure.
But, don't .shift() twice in your function.
Because then you'd be removing two elements.
Mario A. Carlos
@MarioC3
May 02 2017 03:04
So how do I return the element that was taken away?
Joseph
@revisualize
May 02 2017 03:04
@MarioC3 return arr.shift();
Mario A. Carlos
@MarioC3
May 02 2017 03:05
ooohhhhh I get it now!
function nextInLine(arr, item) {
  // Your code here
  arr.push(item);
  return arr.shift();  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 4)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Thanks @revisualize
CamperBot
@camperbot
May 02 2017 03:05
marioc3 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3873 | @revisualize |http://www.freecodecamp.com/revisualize
Mario A. Carlos
@MarioC3
May 02 2017 03:06
I was repeating myself!
Dazaev
@dazaevvc
May 02 2017 03:07

var Car = function(wheels, seats, engines) {
//Change this constructor
this.wheels = 4;
this.seats = 5;
this.engines = 1;
};

//Try it out here
var myCar = new Car(4,2,0);

is there something weird in my code?
i think its perfectly correct
but it keeps giving me the same values on the top side for those properties
instead of the 4,2,0
Michael Grienauer
@mgrienauer
May 02 2017 03:08
@cmccormack i read that scripts were supposed to go at bottom of body?
so that the page can load first
is that wrong
Christopher McCormack
@cmccormack
May 02 2017 03:09
@mike93og93 it’s not wrong; however, I believe FCC teaches us the jquery $(document).ready(function() { } ) specifically for that
there are also non-jquery ways to do it
adding this function allows you to add code that requires the DOM to be fully loaded while still loading your scripts in the <head>
rlgerman25
@rlgerman25
May 02 2017 03:10
Hi, guys. I need some help with my code.
Christopher McCormack
@cmccormack
May 02 2017 03:11
Codepen does load your JS at the bottom of your HTML, you can inspet the page with the browser developer tools and see it
Dan V
@DV1988
May 02 2017 03:11
Hi could use some help on this JAva Script
im stuck
jhobotuck
@jhobotuck
May 02 2017 03:11
I really don't get this filter function. Can someone steer me in the right direction.
function destroyer(arr) {

  var resultArray = [];

  resultArray = arr.filter(function(val){

    for (var i = 0; i < arr.length - 1; i++) {
      if (val === arguments[i + 1]) {
        return true;
      } else {
        return false;
      }
    }


  });

  return resultArray;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Christopher McCormack
@cmccormack
May 02 2017 03:12
@dazaevvc you need to change your function variables to be equal to the parameters of the function, not Number literals
jsrengg
@jsrengg
May 02 2017 03:12
blob
Hii can someone help me with this? Sorry I'm not sure if I'm inserting the picture correctly
It's for the Stand in Line challenge
This is the code but I keep getting TypeError: arr.shift is not a function
Christopher McCormack
@cmccormack
May 02 2017 03:14
@jhobotuck in your for loop, because you’re using i < you should not require the arr.length - 1. Also, if your arr is longer than 2 numbers your val === arguments[i+1] isn’t going to work, so you may think of redoing the logic on that piece
@jsrengg push() and shift() are in-place methods
jhobotuck
@jhobotuck
May 02 2017 03:15
Thanks @cmccormack
CamperBot
@camperbot
May 02 2017 03:15
jhobotuck sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 495 | @cmccormack |http://www.freecodecamp.com/cmccormack
Christopher McCormack
@cmccormack
May 02 2017 03:16
@jsrengg you’re overriding your array with the length of your array by making arr=arr.push(item)
rlgerman25
@rlgerman25
May 02 2017 03:17
Is there a way to sum parameters in JavaScript? I am counting cards.
Christopher McCormack
@cmccormack
May 02 2017 03:17
@rlgerman25 count+=1 or count-=1
@rlgerman25 shouldn’t be doing anything with the parameters other than checking what they are and modifying count
Joseph
@revisualize
May 02 2017 03:19
@rlgerman25 Yes.
@rlgerman25 for cc(card) there is just 1 parameter.
rlgerman25
@rlgerman25
May 02 2017 03:20
True. So how do I tell my function it to add the imputed data?
Thanks, @revisualize and @cmccormack .
CamperBot
@camperbot
May 02 2017 03:20
rlgerman25 sends brownie points to @revisualize and @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 496 | @cmccormack |http://www.freecodecamp.com/cmccormack
:star2: 3874 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
May 02 2017 03:20
@rlgerman25 Look you're trying to over-complicate the function.
@rlgerman25 In JavaScript (and some other C based programming languages) the ; is a statement terminator.
@rlgerman25 Doing cc(9); cc(2); cc("J"); ... That is 3 separate function calls.
jsrengg
@jsrengg
May 02 2017 03:21
@cmccormack I'm still a bit confused. Could you explain a bit more? wouldn't push(item) add the item onto the array?
Joseph
@revisualize
May 02 2017 03:21
@rlgerman25 Because the ; terminates the previous statement.
rlgerman25
@rlgerman25
May 02 2017 03:21
I know that part
Joseph
@revisualize
May 02 2017 03:22
@rlgerman25 You can't take cc(9); cc(2); cc("J"); and turn it into one function call.
rlgerman25
@rlgerman25
May 02 2017 03:23
I understand now!
Silly me @revisualize . It is uspposed to take one input at a time, not several.
Therefore, no need to sum my function calls.
Gulsvi
@gulsvi
May 02 2017 03:25
Practicing, and curious... is this an efficient way to count all negative numbers in a sorted 2D array? The break; seems horrible to me for some reason...
const arr = [[-3, -2, -1, 1], [-2, 2, 3, 4], [-5, -4, 7, 8]];

function getNumberOfNegatives(arr) {
  let count = 0;
  for (let i = 0; i < arr.length; i++) {
    for (let j = arr[i].length - 1; j >= 0; j--) {
      if (arr[i][j] < 0) {
        count += j + 1;
        break;
      }
    }
  }
  return count;
}

getNumberOfNegatives(arr);
cusbus
@cusbus
May 02 2017 03:26
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },

];


function lookUpProfile(firstName, prop){
// Only change code below this line
   for (i=0; i < contacts.length; i++) {
    if (firstName === contacts.firstName) {
      return firstName;
    } else { 
    return "No such contact";
   }
  }
jhobotuck
@jhobotuck
May 02 2017 03:27
@cmccormack Is right assume that the filter() function will loop through val in the if statement or does this aspect need to be changed?
cusbus
@cusbus
May 02 2017 03:27
sorry to barge in. can anyone shed some light on why contacts.firstName is not pulling the value in the dataset?
Christopher McCormack
@cmccormack
May 02 2017 03:27
@jhobotuck filter loops through arr, it’s an array method you’re calling on arr. val is the current value in the array
Mauro
@mauronml
May 02 2017 03:27
@cusbus you are returning the same variable that was passed as an argument
@cusbus namely firstName
Christopher McCormack
@cmccormack
May 02 2017 03:28
@cusbus you’re also returning after the first contact without looking at any more contacts, and you don’t have a return for the “No such property” string as the instructions require
cusbus
@cusbus
May 02 2017 03:29
@cmccormack yea, i am trying to break it down into functional chunks before adding more
lookUpProfile("Akira", "likes")
Dan V
@DV1988
May 02 2017 03:29
myVar =i++;----wahts wrong with this line of code?
Jose Diaz
@jsd540
May 02 2017 03:29
for the mutations project... am I supposed to only use .indexOf() and lastIndexOf() ? I've been trying to figure this out but whenever I do I get more -1's than I should . In other words no matter how I use these 2 methods I will always get either true or false making the rest of the test cases fail?
jhobotuck
@jhobotuck
May 02 2017 03:29
@cmccormack True. So it loops through arr? Because it the val value stores the arr values.
Mauro
@mauronml
May 02 2017 03:30
@cusbus and your condition in your if statement is not actually comparing to the objects firstName property. You are missing the array index
Christopher McCormack
@cmccormack
May 02 2017 03:30
@DV1988 depends on what you’re trying to do, but that will assign the initial value of i to myVar then increment i
bitcoinabdi
@bitcoinabdi
May 02 2017 03:31
good evening folks
i have a question that i need your help with
Jose Diaz
@jsd540
May 02 2017 03:31
@DV1988 I don't think you can initialize and increment at the same time.
cusbus
@cusbus
May 02 2017 03:31
yes! that is what i was hoping to do. be it the correct solution or not, i can't figure out why the right hand side of the if (firstName === contacts.firstName) { doesn't check the property?
bitcoinabdi
@bitcoinabdi
May 02 2017 03:31
i have been banging y head on the wall for sometime trying to figure this question out
Christopher McCormack
@cmccormack
May 02 2017 03:31
@jhobotuck not quite certain what you’re saying, but yes it’s looping through arr, and for each pass through the loop val is assigned the current value in arr
Mauro
@mauronml
May 02 2017 03:32
@cusbus remember that contacts is an array. To access an element in array, you have to provide it an index []
Christopher McCormack
@cmccormack
May 02 2017 03:32
@bitcoinabdi what is your question?
cusbus
@cusbus
May 02 2017 03:32
thanks @mauronml ! I'll see if i can figure it out
CamperBot
@camperbot
May 02 2017 03:32
cusbus sends brownie points to @mauronml :sparkles: :thumbsup: :sparkles:
:cookie: 219 | @mauronml |http://www.freecodecamp.com/mauronml
Dan V
@DV1988
May 02 2017 03:32
yeah I am trying to get I=88, so the code I am writing looks like this myVar=i++; if i=87 i should get a value of 88, right?
jhobotuck
@jhobotuck
May 02 2017 03:33
@cmccormack Sorry. I'm trying my best. So the function compares the individual values of "val" with the other side of the if statement?
Mauro
@mauronml
May 02 2017 03:33
@cusbus well, to be more specific, contacts is an array of objects. So to get the value of the firstName property from the first object you would use contacts[0].firstName
bitcoinabdi
@bitcoinabdi
May 02 2017 03:33
function repeatStringNumTimes(str, num) {
  // repeat after me

  if(num > 0){
    return str.repeat(num);
  }
  else if(num <= -0){ 
    return ("");
  }
  else{
    return ("");
  }
}


repeatStringNumTimes("abc", -2);
please help
@revisualize please help
Curtis Tebbe
@frigidkap
May 02 2017 03:35
function lookUpProfile(firstName, prop){
// Only change code below this line
  for (i = 0; i < contacts.length; i++) {
    if (contacts[i].firstName == firstName) {
      if (contacts[i].hasOwnProperty(prop) === true) {
          return contacts[i][prop];
        } else { return "No such property";}
      } else { return "No such contact";}
    }

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
bitcoinabdi
@bitcoinabdi
May 02 2017 03:35
``` (shift+enter for line break)
var code = "formatted";
```
Curtis Tebbe
@frigidkap
May 02 2017 03:35
I'm stuck... any help?
bitcoinabdi
@bitcoinabdi
May 02 2017 03:35
``` 

function truncateString(str, num) {
// Clear out that junk in your trunk

if(num ==str.length){
return str+"...";
} else if(num < str.length) {
return str.slice(0,num)+"...";
}

}

truncateString("A-tisket a-tasket A green and yellow basket", 11);

```

Joseph
@revisualize
May 02 2017 03:36

@DV1988

var num = 5;
num = num + 1; // 6
num += 1; // 7
num++; // 8

See how the one for getting num from 7 to 8 doesn't use the assignment operator (=)?
The lesson is requesting that you recreate that process so that you know how to increment and decrement a number with short notation.

Christopher McCormack
@cmccormack
May 02 2017 03:36
@jhobotuck the way I saw it last in your code was not going to work, so I don’t want to explain the code too much, just know that the filter function iterates over each value in an array, and what you return within the function inside filter (true or false) determines if the number will be allowed to stay in the array (true) or be removed (false)
Joseph
@revisualize
May 02 2017 03:36
@bitcoinabdi Let's see. Let me pull up that lesson.
bitcoinabdi
@bitcoinabdi
May 02 2017 03:36
```

function truncateString(str, num) {
// Clear out that junk in your trunk

if(num ==str.length){
return str+"...";
} else if(num < str.length) {
return str.slice(0,num)+"...";
}

}

truncateString("A-tisket a-tasket A green and yellow basket", 11);

```

Joseph
@revisualize
May 02 2017 03:36
@cwborion Stand in Line is NOT a normal challenge. It is a CheckPoint.
jhobotuck
@jhobotuck
May 02 2017 03:36
Thanks for you help @cmccormack
CamperBot
@camperbot
May 02 2017 03:36
jhobotuck sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:warning: jhobotuck already gave cmccormack points
bitcoinabdi
@bitcoinabdi
May 02 2017 03:37
@revisualize its actualy Truncate a string
Branden Ng
@BrandenDaniel
May 02 2017 03:37
hello people
Joseph
@revisualize
May 02 2017 03:37
@frigidkap Your function is returning too early and not actually looping.
Branden Ng
@BrandenDaniel
May 02 2017 03:38
having an issue Private properties
var Bike = function() {

  // Only change code below this line.
  var gear;

  this.getGear = function(){

  };


  this.setGear = function(){

  };

};

var myCar = new Car();

var myBike = new Bike();
myBike.setGear = Bike();
bitcoinabdi
@bitcoinabdi
May 02 2017 03:38
function truncateString(str, num) {
  // Clear out that junk in your trunk


  if(num ==str.length){
    return str+"...";
  } else if(num < str.length) {
    return str.slice(0,num)+"...";
  }

}

truncateString("A-tisket a-tasket A green and yellow basket", 11);
that is the question
Joseph
@revisualize
May 02 2017 03:39
@bitcoinabdi So, your else if return statement has 3 too many characters.
Dan V
@DV1988
May 02 2017 03:39
myVar = myVar should be changed
how do i get that requirement checked of
Joseph
@revisualize
May 02 2017 03:39

@DV1988

var num = 5;
num = num + 1; // 6
num += 1; // 7
num++; // 8

See how the one for getting num from 7 to 8 doesn't use the assignment operator (=)?
The lesson is requesting that you recreate that process so that you know how to increment and decrement a number with short notation.

Caleb Brenner
@cwborion
May 02 2017 03:39
@revisualize I suppose that makes sense. I just feel like it's so vague based off of the information already covered, that there's not even really a worthwhile to search for how to do it right, because it uses elements that have been seen, but not yet described. I enjoy figuring out the ones I struggle with and I usually can online, but this one is so vague that I don't feel like there's any way I could have figured it out without cheating or having someone basically just tell me in a chatroom.
Joseph
@revisualize
May 02 2017 03:39
@DV1988 What code do you have?
@cwborion Sure there is.
Dan V
@DV1988
May 02 2017 03:40

var myVar = 87;

// Only change code below this line
myVar =88;
myVar =myVar++;

Joseph
@revisualize
May 02 2017 03:41
@DV1988 remove: myVar =88;
Caleb Brenner
@cwborion
May 02 2017 03:41
@revisualize how would you suggest going about it differently?
Joseph
@revisualize
May 02 2017 03:41
@DV1988 When I did num++ did I have an = sign?
Christopher McCormack
@cmccormack
May 02 2017 03:41

@cwborion there were some previous exercises that have all the explanation you should need:

Manipulate Arrays With push
Manipulate Arrays With pop
Manipulate Arrays With shift
Manipulate Arrays With unshift

Read through these again then go back to Stand in LIne

Joseph
@revisualize
May 02 2017 03:41
@cwborion
// A lookUpProfile function that takes
// firstName and a property (prop)
// as parameters has been pre-written for you.
function lookUpProfile(firstName, prop){
   // The function should check if firstName is an actual contact's firstName
   // and the given property (prop) is a property key of that contact.

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

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


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

}
bitcoinabdi
@bitcoinabdi
May 02 2017 03:41
function truncateString(str, num) {
  // Clear out that junk in your trunk

  var ab = str.length;

  if(num ==ab){
    return str+"...";
  } else if(num < ab) {
    return str.slice(0,num)+"...";
  }

}

truncateString("A-tisket a-tasket A green and yellow basket", 11);
Joseph
@revisualize
May 02 2017 03:41
@cwborion I've solved that challenge 4(?) different ways.
bitcoinabdi
@bitcoinabdi
May 02 2017 03:42
how about that @revisualize
Dan V
@DV1988
May 02 2017 03:42
then it gives me 87
Joseph
@revisualize
May 02 2017 03:42
@bitcoinabdi You're completely missing 1 whole if block.
@DV1988 Show me.
@cwborion You're actually really close to solving it.
Dan V
@DV1988
May 02 2017 03:43
just figured it out
thanks everyone, it was myVar++....... WOOWWSSS
Joseph
@revisualize
May 02 2017 03:43
@cwborion Let's say you were at a big business event and you're quite popular (with all those skills you have) throughout the event you got handed 200 business cards (Which will remain unordered). Now, I walk up to you at the end and ask you.. Do you have a Business Card for "Jane Smith"? Now you loop look through your stack of 200 business cards. When would you tell me that you didn't have a business card for Jane?
bitcoinabdi
@bitcoinabdi
May 02 2017 03:43
@revisualize one whole if block for what ?
Joseph
@revisualize
May 02 2017 03:43
@bitcoinabdi Re-read the instructions.
Branden Ng
@BrandenDaniel
May 02 2017 03:43
@revisualize will you be able to provide some hints perhaps?
Joseph
@revisualize
May 02 2017 03:44
@BrandenDaniel To what?
Dan V
@DV1988
May 02 2017 03:44

var myVar = 87;

// Only change code below this line

myVar++;

Branden Ng
@BrandenDaniel
May 02 2017 03:44
var Car = function() {
  // this is a private variable
  var speed = 10;

  // these are public methods
  this.accelerate = function(change) {
    speed += change;
  };

  this.decelerate = function() {
    speed -= 5;
  };

  this.getSpeed = function() {
    return speed;
  };
};

var Bike = function() {

  // Only change code below this line.
  var gear;

  this.getGear = function(){
    return myBike.setGear();
  };


  this.setGear = function(){

  };

};

var myCar = new Car();

var myBike = new Bike();
Dan V
@DV1988
May 02 2017 03:44
that's the final
Thanks everyone again
Caleb Brenner
@cwborion
May 02 2017 03:44
@cmccormack yes, I remember those, and it makes sense that they'd be used. Those exercises don't have functions in them or "return" so you're implementing them into an environment that you haven't even witnessed before, so I don't understand how you're supposed to just guess how it should be applied.
@revisualize after looking through the entire pile?
Christopher McCormack
@cmccormack
May 02 2017 03:45

@cwborion there are others still prior to that one…

Return a Value from a Function with Return
Assignment with a Returned Value

Joseph
@revisualize
May 02 2017 03:46
@cwborion crap. I'm sorry, I'm confused. I thought you were working on something else.
Christopher McCormack
@cmccormack
May 02 2017 03:46
they’re literally right before Stand in Line
Joseph
@revisualize
May 02 2017 03:46
@frigidkap Hey.
@cwborion I'm sorry, Forgive me. I thought you were working on something else.
Caleb Brenner
@cwborion
May 02 2017 03:47
@revisualize no worries
Branden Ng
@BrandenDaniel
May 02 2017 03:47
nevermind i'll come back at a later time
Joseph
@revisualize
May 02 2017 03:49
@BrandenDaniel Good luck.
bitcoinabdi
@bitcoinabdi
May 02 2017 03:49
```

function truncateString(str, num) {
// Clear out that junk in your trunk

var ab = str.length;

if(num ==ab){
return str+"...";
} else if(num < ab) {
return str.slice(0,num)+"...";
}else if (num <=3){
return str+"...";
} else {
return str.slice(0,num)+"...";
}

}

truncateString("A-tisket a-tasket A green and yellow basket", 11);

```

@revisualize
@revisualize please help
Caleb Brenner
@cwborion
May 02 2017 03:50
@cmccormack Yes, I understand the way that everything that is supposed to used, from doing those exercises, but I would never have guessed to write it in that way particularly without seeing something exactly the same but with different values before
Christopher McCormack
@cmccormack
May 02 2017 03:50
@BrandenDaniel you need to actually do something in your setGear function
Joseph
@revisualize
May 02 2017 03:50
@bitcoinabdi However, if the given maximum string length num is less than or equal to 3, then the addition of the three dots does not add to the string length in determining the truncated string.
Branden Ng
@BrandenDaniel
May 02 2017 03:52
@cmccormack hmm..
Joseph
@revisualize
May 02 2017 03:52
@bitcoinabdi Look: truncateString("A-tisket a-tasket A green and yellow basket", 11) should return "A-tisket..."
What is "A-tisket...".length ?
@bitcoinabdi What is "A-tisket a-tasket A green and yellow basket".slice(0, 11)?
Branden Ng
@BrandenDaniel
May 02 2017 03:54
@cmccormack do both setgear and getgear function return something?
Joseph
@revisualize
May 02 2017 03:54
@bitcoinabdi
"A-tisket...".length is 11
"A-tisket a-tasket A green and yellow basket".slice(0, 11) is:
"A-tisket a-"
But, it should be returning:
"A-tisket..."
Christopher McCormack
@cmccormack
May 02 2017 03:55
@BrandenDaniel technically, yes, but you’re only required to ensure the getGear returns the correct value/type. A function with no return statement in Javascript will still return undefined
@BrandenDaniel those two types of functaions are called mutators and accessors and are more of an OOP concept
Branden Ng
@BrandenDaniel
May 02 2017 03:58
@cmccormack alright thanks for the info
CamperBot
@camperbot
May 02 2017 03:58
brandendaniel sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 497 | @cmccormack |http://www.freecodecamp.com/cmccormack
loganTharbin
@loganTharbin
May 02 2017 04:37
hey if anyone could help me i would really appreciate it . i have been stuck on this converting Celsius to Fahrenheit challenge .
heroiczero
@heroiczero
May 02 2017 04:37
@loganTharbin lets see your code
loganTharbin
@loganTharbin
May 02 2017 04:37
alright one sec

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line

// Only change code above this line
return fahrenheit;
}

// Change the inputs below to test your code
convertToF(30);

Nahuel Ovejero
@NahuelOvejero
May 02 2017 04:39
@loganTharbin you need to apply the math function on the example
heroiczero
@heroiczero
May 02 2017 04:39
T(°F) = T(°C) × 9/5 + 32 @loganTharbin this is your formula but remember to usefahrenheit and celsius
loganTharbin
@loganTharbin
May 02 2017 04:39
t represent what?
Joseph
@revisualize
May 02 2017 04:40
@loganTharbin There is the function declaration of function convertToF(celsius) { .. You have a function name of convertToF and a parameter of celsius
Parameters are used just like variables. So, inside of the function you can use celsius JUST like any other variable.
The algorithm to convert from Celsius to Fahrenheit is the temperature in Celsius times 9/5, plus 32
heroiczero
@heroiczero
May 02 2017 04:41
T is the temperature
Joseph
@revisualize
May 02 2017 04:42

If I have this code:

function addThree (num) {
    var result;
    result = num + 3;
    return result;
}

So, when we make the function call of:

addThree(10);

You're calling the function addThree You're also passing a value 10 as an argument.
In the function declaration of function addThree (num) { You see that there is a parameter defined of num
When we do addThree(10) then the value of the parameter num is passed the argument value of ... 10
Then if you follow the code through.. result = num + 3; ... and we know the value of num is 10.
Therefore, if we follow through the function we end up with ... result = 10 + 3; then result = 13; then we return the result.
...
If you then make another function call..

addThree(39);

You can use the same function to follow the operation:
When we do addThree(39) then the value of the parameter num is passed the argument value of ... 39
Then if you follow the code through.. result = num + 3; ... and we know the value of num is now 39.
Therefore, if we follow through the function we end up with ... result = 39 + 3; then result = 42; then we return the result.

If you make the function call of addThree(21) the value of num inside the function is 21.
If you make the function call of addThree(1000) the value of num inside the function is 1000.
If you make the function call of addThree(123456) the value of num inside the function is 123456.

function declaration of function convertToF(celsius) { } making the function call convertToF(55) the parameter celsius inside of the function has a value of 55
function declaration of function convertToF(celsius) { } making the function call convertToF(23) the parameter celsius inside of the function has a value of 23
loganTharbin
@loganTharbin
May 02 2017 04:43
@heroiczero oh alright i think i am starting to understand so if im trying to get a return value of 86 using 30 i should plug 30 into the c part of the equation
Ian Arsenault
@ianarsenault
May 02 2017 04:43
Banging my head. Just spent all day trying to work on the Roman Numeral Converter, only to get it after.. Then check the wiki , and the solution is far more easier than I made it out to be. Doh!
Joseph
@revisualize
May 02 2017 04:44
@loganTharbin All of that text that I just posted is for you.
about @GorgonsMaze
CamperBot
@camperbot
May 02 2017 04:45
:cookie: 339 | @gorgonsmaze |http://www.freecodecamp.com/gorgonsmaze
Joseph
@revisualize
May 02 2017 04:45
@GorgonsMaze You made that REALLY complicated.
Ian Arsenault
@ianarsenault
May 02 2017 04:45
llol yeah
I'm usually somewhat close, but that. I made it really difficult.
rugano
@rugano
May 02 2017 04:46
function slasher(arr, howMany){
   // it doesn't always pay to be first
     var slash = [ ];

          while(arr.length > 0){

              var n = [ ];
            for(var i = 0;i < arr.length;i++){

         var ele = [ ];
         if(ele !== undefined){

      arr.splice(n);
   }
}
slash.push(arr.length-n);
  }
return arr;
}

slasher([1,2,3], 2);
how do i correct this code?
loganTharbin
@loganTharbin
May 02 2017 04:46
@revisualize thank you
CamperBot
@camperbot
May 02 2017 04:46
logantharbin sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3875 | @revisualize |http://www.freecodecamp.com/revisualize
Cosmo Alves
@CosmoAlves
May 02 2017 04:52
Hi people, i need help again

var answer = "";
// Only change code below this line

switch (val) {
case 1:
answer = "Marley";
break;
case 2:
answer = "The Answer";
break;
case 3:
answer = "There is no #1";
break;
case 4:
answer = "Missed me by this much!";
break;
case 5:
answer = "Ate Nine";
break;
}

// Only change code above this line
return answer;
}

// Change this value to test
chainToSwitch("bob");
chainToSwitch(1);

diegoxro
@diegoxro
May 02 2017 04:53
@rugano why while and loop to go over the same array?
Markus Kiili
@Masd925
May 02 2017 04:54
@rugano One method call is enough on this challenge.
diegoxro
@diegoxro
May 02 2017 04:55
@CosmoAlves chainToSwitch("bob"); will not match anything , what's the challenge again?
Markus Kiili
@Masd925
May 02 2017 04:55
@jf4nathan .prop looks for property key "prop". Not what you wan't here.
J Tang
@jf4nathan
May 02 2017 04:55
function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i++) {
  if (contacts[i].firstName == firstName) {
      if (contacts[i].hasOwnProperty(prop) ) {
        return contacts[i].prop;
      }

    else return "No such property";
    }
  else return "No such contact";

    }

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Kristian", "lastName");
ok thanks @Masd925 that helps I'll try to fix it
Markus Kiili
@Masd925
May 02 2017 04:56
@jf4nathan The logic for returning No such contact is also wrong.
Cosmo Alves
@CosmoAlves
May 02 2017 04:56
@diegoxro it's Replacing If Else Chains with Switch
J Tang
@jf4nathan
May 02 2017 04:56
Is the logic you're referring to this?
if (contacts[i].firstName == firstName)
Markus Kiili
@Masd925
May 02 2017 04:57
@jf4nathan Conditions are fine. You just cannot return No such contact until you have checked all the contacts.
diegoxro
@diegoxro
May 02 2017 04:58
@CosmoAlves i get that but bob will not match your cases so, is this the one where you have to add a default case?
J Tang
@jf4nathan
May 02 2017 05:00
@Masd925 how do I make it check all the contacts before the else statement?
Cosmo Alves
@CosmoAlves
May 02 2017 05:00
@diegoxro ok, i'll try that
Markus Kiili
@Masd925
May 02 2017 05:00
@jf4nathan Return inside the loop if you find the contact and after the loop if you don't.
cusbus
@cusbus
May 02 2017 05:01
i've been trying something similar to j tang, but it doesn't seem to be looping though the full array...
Cosmo Alves
@CosmoAlves
May 02 2017 05:10

```function chainToSwitch(val) {
var answer = "";
// Only change code below this line

switch (val) {
default:
answer = "Marley";
break;
case 1:
answer = "There is no #1";
break;
case 42:
answer = "The Answer";
break;
case 99:
answer = "Missed me by this much!";
break;
case 7:
answer = "Ate Nine";
break;

case 156:
  answer = "";

}

// Only change code above this line
return answer;
}

// Change this value to test

chainToSwitch(1);```

Now, only one doesn't worked
diegoxro
@diegoxro
May 02 2017 05:12
what are the test cases
Cosmo Alves
@CosmoAlves
May 02 2017 05:13
You should not use any else statements anywhere in the editor
You should not use any if statements anywhere in the editor
You should have at least four break statements
chainToSwitch("bob") should be "Marley"
chainToSwitch(42) should be "The Answer"
chainToSwitch(1) should be "There is no #1"
chainToSwitch(99) should be "Missed me by this much!"
chainToSwitch(7) should be "Ate Nine"
chainToSwitch("John") should be "" (empty string)
chainToSwitch(156) should be "" (empty string)
Only this "chainToSwitch("John") should be "" (empty string)" is not working
Joseph
@revisualize
May 02 2017 05:14
@CosmoAlves Why not just make a default case for empty string?
@CosmoAlves OH!
@CosmoAlves You have your default case at the top of the switch.
rugano
@rugano
May 02 2017 05:15
@Masd925 @diegoxro thanks,got it
CamperBot
@camperbot
May 02 2017 05:15
rugano sends brownie points to @masd925 and @diegoxro :sparkles: :thumbsup: :sparkles:
Joseph
@revisualize
May 02 2017 05:15
@CosmoAlves That won't work.
CamperBot
@camperbot
May 02 2017 05:15
:star2: 3978 | @masd925 |http://www.freecodecamp.com/masd925
:cookie: 151 | @diegoxro |http://www.freecodecamp.com/diegoxro
Markus Kiili
@Masd925
May 02 2017 05:15
@rugano :+1:
Joseph
@revisualize
May 02 2017 05:15
@CosmoAlves chainToSwitch("bob") should be "Marley"
diegoxro
@diegoxro
May 02 2017 05:16
i dont remember this challenge but also "John" needs a case based on your info case "John"
and return "" (empty string );
Damien
@DubbDevs
May 02 2017 05:16
can I get some assistance with Using Objects for Lookup
Joseph
@revisualize
May 02 2017 05:16
@diegoxro "John" doesn't really need a case if they use default:
@DubbDevs Sure.
francescacosta
@francescacosta
May 02 2017 05:16

Hi Guys,

I was hoping I could get some help on the "Chunky Monkey challenge. I'm having difficulty deciding what the first move is

Joseph
@revisualize
May 02 2017 05:16
@DubbDevs Whatcha got?
Damien
@DubbDevs
May 02 2017 05:17
besides mass confusion
Markus Kiili
@Masd925
May 02 2017 05:17
@francescacosta A loop of some kind is needed.
Joseph
@revisualize
May 02 2017 05:17
@francescacosta Loop
Damien
@DubbDevs
May 02 2017 05:17
// Setup
function phoneticLookup(val) {
  var result = "";

  // Only change code below this line
  var lookup = {
    alpha:"Adams",
    bravo:"Boston",
    charlie:"Chicago",
    delta:"Denver",
    echo:"Easy",
    foxtrot:"Frank",
  };


  // Only change code above this line
  return result;
}

// Change this value to test
phoneticLookup("charlie");
diegoxro
@diegoxro
May 02 2017 05:17
@revisualize right
Joseph
@revisualize
May 02 2017 05:17
@DubbDevs Okay! That's good.
Damien
@DubbDevs
May 02 2017 05:17
I'm hoping that's right so far
Joseph
@revisualize
May 02 2017 05:18
@DubbDevs That's correct so far. However, 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 to be the value of the property from the object that you created.
Damien
@DubbDevs
May 02 2017 05:18
i know the next step is to access obj property with varibles and that's where I'm turned around
Joseph
@revisualize
May 02 2017 05:18
@DubbDevs Okay.
@DubbDevs So, The function declaration was set up as... function phoneticLookup(val) giving the function name as phoneticLookup and with the parameter of val. There is more that I could go into (if you want I can) but, I'll sum it up with: Parameters are variable-like objects that represent the values that get passed into your function from the function call (arguments). (You basically treat them like variables.)
@DubbDevs So, as we learned in: Accessing Objects Properties with Variables you have to use bracket notation to access an object property with a variable. Example: var num = 42; myObj[num];
@DubbDevs You just need to modify the variable result to be the value of the object property for the lookup object.
@DubbDevs Any questions?
Damien
@DubbDevs
May 02 2017 05:20
ok that's where the val comes in
Joseph
@revisualize
May 02 2017 05:20
@DubbDevs Yeah.
Cosmo Alves
@CosmoAlves
May 02 2017 05:20
@revisualize The default case must comes at the end of the switch?
Joseph
@revisualize
May 02 2017 05:21
@CosmoAlves That's where I've always seen it.. I don't know if it is a "must" but, I'm pretty sure that's standard.
@CosmoAlves The person to ask if it is a "must" would be @Masd925
revisualize @revisualize goes afk. Laundry => dryer
francescacosta
@francescacosta
May 02 2017 05:23

@Masd925 @revisualize I started this with my partner... but couldn't get it to work... not quite sure where to go next
var num_loops = arr.length / size

var result = []

for (var start = 0; start <= size; start += size) {
result.push( arr.slice(start, size) );

size += size

}

arr = result
return arr;
}

gerome0123
@gerome0123
May 02 2017 05:23
how to get an array object by the id?
Cosmo Alves
@CosmoAlves
May 02 2017 05:23
@Masd925 The default case must comes at the end of the switch?
diegoxro
@diegoxro
May 02 2017 05:24
from the docs " Can I put a default between cases? Yes you can! JavaScript will drop you back to the default if it can't find a match:"
gerome0123
@gerome0123
May 02 2017 05:25
name = [[id: 1 , name: 'Name1', [ id :2 name: 'Name2']]
how to get array object by id?
Joseph
@revisualize
May 02 2017 05:26
@gerome0123 Ummm.. Is that correct?
diegoxro
@diegoxro
May 02 2017 05:26
@revisualize yeah that does not seem right
Joseph
@revisualize
May 02 2017 05:27
@gerome0123 id: 1 I haven't seen that outside of an object before.
Cosmo Alves
@CosmoAlves
May 02 2017 05:27
@Masd925 @revisualize @diegoxro , thanks for the help, now worked
CamperBot
@camperbot
May 02 2017 05:27
cosmoalves sends brownie points to @masd925 and @revisualize and @diegoxro :sparkles: :thumbsup: :sparkles:
:cookie: 152 | @diegoxro |http://www.freecodecamp.com/diegoxro
:star2: 3979 | @masd925 |http://www.freecodecamp.com/masd925
:star2: 3876 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
May 02 2017 05:27
@gerome0123 Your name variable is all malformed. It doesn't make sense.
gerome0123
@gerome0123
May 02 2017 05:28
myName = [[id: 1 , name: 'Name1', [ id :2 name: 'Name2']]
Joseph
@revisualize
May 02 2017 05:28
@gerome0123 That isn't correct.
@gerome0123 You're at least missing a ] somewhere.
@gerome0123 What is id: 1 as an array element?
@gerome0123 I don't understand this array: [ id :2 name: 'Name2']
gerome0123
@gerome0123
May 02 2017 05:31
Array[2]
0:Object
name:"Name1"
1:Object
name:"Name2"
my console
Array[2]
0:Object id:1
name:"Name1"
1:Object id: 2
name:"Name2"
Joseph
@revisualize
May 02 2017 05:32
blob
@gerome0123 This is what my console is showing.
cusbus
@cusbus
May 02 2017 05:33
@jf4nathan hey man - did you figure that lastone out? I've been at it all evening and cannot find the solution....
gerome0123
@gerome0123
May 02 2017 05:34
then how can i get that by id??
Joseph
@revisualize
May 02 2017 05:34

@gerome0123 I don't understand this array: [ id :2 name: 'Name2']

@gerome0123 Could you explain what that is to me?

@gerome0123 You can't. It is a malformed variable.
var myName = [[id: 1 , name: 'Name1', [ id :2 name: 'Name2']]
VM50:1 Uncaught SyntaxError: Unexpected token :
That is incorrect.
gerome0123
@gerome0123
May 02 2017 05:34
ok my bad
im using push
Joseph
@revisualize
May 02 2017 05:35
@gerome0123 Which freeCodeCamp challenge is this? I have no idea what you're doing.
gerome0123
@gerome0123
May 02 2017 05:36
i was changing my data for an exaple
example
Joseph
@revisualize
May 02 2017 05:36
@gerome0123 Well, your example isn't correct.
gerome0123
@gerome0123
May 02 2017 05:37
sorry
let me explain it again :)
Riley
@Riley1435
May 02 2017 05:37
This seems to be correct but it does not seem to be working.

var oldArray = [1,2,3,4,5];

// Only change code below this line.
var newArray = oldArray.map(function(val) {
return val + 3;
});
var newArray = oldArray;

gerome0123
@gerome0123
May 02 2017 05:37
i declare an array sample = []
Joseph
@revisualize
May 02 2017 05:37
@Riley1435 It isn't correct.
diegoxro
@diegoxro
May 02 2017 05:38
@Riley1435 you are reassigning i think
gerome0123
@gerome0123
May 02 2017 05:38
then i have new form that i need to fill up
Riley
@Riley1435
May 02 2017 05:38
change the var newArray to a different variable?
gerome0123
@gerome0123
May 02 2017 05:38
when i finish to fill up i push to my array
Joseph
@revisualize
May 02 2017 05:38
@Riley1435 You're modifying newArray to be a map of the oldArray. Then you're overwriting the new value with the previous oldArray.
Riley
@Riley1435
May 02 2017 05:38
like var plusThree
diegoxro
@diegoxro
May 02 2017 05:38
here , this will overrride var newArray = oldArray;
Joseph
@revisualize
May 02 2017 05:38
@gerome0123 Which freeCodeCamp lesson is this?
Riley
@Riley1435
May 02 2017 05:38
iterate over Arrays with map
Joseph
@revisualize
May 02 2017 05:39
@Riley1435 Just remove this line: var newArray = oldArray;
gerome0123
@gerome0123
May 02 2017 05:39
no one?
diegoxro
@diegoxro
May 02 2017 05:39
@Riley1435 yes you have already done that , no need for var newArray = oldArray;
Riley
@Riley1435
May 02 2017 05:39
okay
it was in there from the start
Joseph
@revisualize
May 02 2017 05:39
@gerome0123 You're not working on a freeCodeCamp lesson?
gerome0123
@gerome0123
May 02 2017 05:39
im just asking for help?
Riley
@Riley1435
May 02 2017 05:39
stupid mistake i should have deleted that line of code
Joseph
@revisualize
May 02 2017 05:40
@gerome0123 Oh, Okay. Good luck.
Riley
@Riley1435
May 02 2017 05:40
thank you
gerome0123
@gerome0123
May 02 2017 05:40
i was searching and i come up here
diegoxro
@diegoxro
May 02 2017 05:40
@Riley1435 var oldArray = [1,2,3,4,5];
// Only change code below this line.
gerome0123
@gerome0123
May 02 2017 05:40
what happen if im not working in code camp?
diegoxro
@diegoxro
May 02 2017 05:41
that means you can edit anything after the line
Riley
@Riley1435
May 02 2017 05:41
I am so used to just adding to FCC's code i didn't even think to overwrite "var newArray = oldArray with the solution i wrote
diegoxro
@diegoxro
May 02 2017 05:41
hard to support , or no support at all
gerome0123
@gerome0123
May 02 2017 05:41
@revisualize what happen if im not working in code camp?
diegoxro
@diegoxro
May 02 2017 05:41
@gerome0123 hard to support , or no support at all
gerome0123
@gerome0123
May 02 2017 05:42
oh
@diegoxro thanks for the reply
CamperBot
@camperbot
May 02 2017 05:42
gerome0123 sends brownie points to @diegoxro :sparkles: :thumbsup: :sparkles:
:cookie: 153 | @diegoxro |http://www.freecodecamp.com/diegoxro
Joseph
@revisualize
May 02 2017 05:42
@gerome0123 Unfortunately, I don't actually know what you're trying to do. We can't get on the same page with the problem you're trying to solve.
Basically, I can't help you.
@gerome0123 You're giving me incorrect information and I don't know how to troubleshoot your problem when you can't articulate your problem correctly.
Ken Haduch
@khaduch
May 02 2017 05:43
@cmurphy580 - should it be this.averageWeight?
Conor Murphy
@cmurphy580
May 02 2017 05:44
@khaduch i want it to only apply to the constructor and not to any of the objects created by the constructor.
gerome0123
@gerome0123
May 02 2017 05:45
ok will explain it
do you support angularjs???
Damien
@DubbDevs
May 02 2017 05:52
@revisualize I'm still at it
I know i should have 2 variables
Joseph
@revisualize
May 02 2017 05:54
@DubbDevs You should technically have three. val the parameter. result and lookup
Rin
@beaRINmind
May 02 2017 05:54
```
var myStr = "FirstLine \n \SecondLine\ \r ThirdLine";

var myStr = "FirstLine \n  \\SecondLine\\ \r ThirdLine";
can i please grab some help with this
Damien
@DubbDevs
May 02 2017 05:56
ok so 3 var and 2 lines
var something = lookup[result];
i want to change the something to val but I get an error saying val is alraedy defined
already*
naveenmehta
@naveenmehta
May 02 2017 05:57
please help...I am not getting it,,,what does assing variable a to varible b mean..? aand hot to do it
Rin
@beaRINmind
May 02 2017 05:58
@naveenmehta it means to assign
naveenmehta
@naveenmehta
May 02 2017 05:58
how*
Rin
@beaRINmind
May 02 2017 05:58
var a = var b
don't forget the semicolon ';' :)
naveenmehta
@naveenmehta
May 02 2017 05:59
its showing n error
Rin
@beaRINmind
May 02 2017 06:00
which challenge number is it?
Damien
@DubbDevs
May 02 2017 06:00
@beaRINmind which challenge are you on I just had that
Rin
@beaRINmind
May 02 2017 06:00
or what is the challenges name?
'Escape Sequences in Strings'
Challenge 145
Johnny
@jtan3
May 02 2017 06:00
@beaRINmind try it without spaces
naveenmehta
@naveenmehta
May 02 2017 06:01
Storing Values with the Assignment Operator
Damien
@DubbDevs
May 02 2017 06:01
@beaRINmind remove the spaces
Rin
@beaRINmind
May 02 2017 06:01
Thanks Guys!!!
diegoxro
@diegoxro
May 02 2017 06:02
you gave var twice , @beaRINmind
Rin
@beaRINmind
May 02 2017 06:02
@naveenmehta ```

// Setup
var a;
var b = 2;

// Only change code below this line
var a = 7;
b = a;
that's what i got for it
naveenmehta
@naveenmehta
May 02 2017 06:03
thankyou sir. @beaRINmind
CamperBot
@camperbot
May 02 2017 06:03
:cookie: 146 | @bearinmind |http://www.freecodecamp.com/bearinmind
naveenmehta sends brownie points to @bearinmind :sparkles: :thumbsup: :sparkles:
Rin
@beaRINmind
May 02 2017 06:03
yeah, whoops, lately ive been doing bootstrap so coming back on this site is confusing me
No worries dude, happy coding!
naveenmehta
@naveenmehta
May 02 2017 06:04
;)
Masaki
@masaki1223
May 02 2017 06:07
I dont understand "Testing Objects for Properties".
Somebody please help me.

// Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp) {
if(myObj.hasOwnProperty(checkProp)===true){
return myObj.checkProp;
}
else{
return "Not Found";
}

}

// Your Code Here

// Test your code by modifying these values
checkObj("gift");

Damien
@DubbDevs
May 02 2017 06:09
sorry @masaki1223 I'm on the challenge behind you and confused as all hell
Masaki
@masaki1223
May 02 2017 06:09
var code="formatted";

var code="formatted";
// Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp) {
if(myObj.hasOwnProperty(checkProp)===true){
return myObj.checkProp;
}
else{
return "Not Found";
}

}

// Your Code Here

// Test your code by modifying these values
checkObj("gift");

Oh sry Im messing it up
Im not sure how to put the typing screen on this chat
Damien
@DubbDevs
May 02 2017 06:10
add 3 ``` before and after your code
Joseph
@revisualize
May 02 2017 06:11
@masaki1223 re: myObj.checkProp; ... Dot Notation is converting the value to a string (string literal). Example: myObj.name; is the same as myObj["name"]; and as we all know quotes define strings. If you want to use a variable for accessing the value of object properties you cannot use Dot Notation. You have to use Bracket Notation. Example: var num = 42; myObj[num];
Masaki
@masaki1223
May 02 2017 06:12
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  if(myObj.hasOwnProperty(checkProp)===true){
    return myObj.checkProp;
  }
else{
  return "Not Found";
}

  }




  // Your Code Here



// Test your code by modifying these values
checkObj("gift");
Joseph
@revisualize
May 02 2017 06:12
@DubbDevs Did you modify the resultvariable to be the value of the property for the lookup object that you created?
Damien
@DubbDevs
May 02 2017 06:16
@revisualize not correctly...every solution I try tells me that result is already defined
i keep refering too accessing object with prop variables but I
Conor Murphy
@cmurphy580
May 02 2017 06:16
is this a function?
Cat.averageWeight = function() {
      return Math.ceil(weights/count);
    }
on my constructor?
Damien
@DubbDevs
May 02 2017 06:17
just can't get it to make sense
Joseph
@revisualize
May 02 2017 06:17
@DubbDevs What did you write?
Damien
@DubbDevs
May 02 2017 06:18
result = lookup[phoneticLookup];
i just wrote that again and got a green so i think I'm close but i know i have to do something with val
var phoneticLookup = val;
result = lookup[phoneticLookup];
var phoneticLookup = val; result = lookup[phoneticLookup];
rks972131
@rks972131
May 02 2017 06:22

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

return 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));
Any one is there to help me out...

Damien
@DubbDevs
May 02 2017 06:22
that worked! though I feel like it was sheer luck I'm going to spend some time looking at it to understand it now
rks972131
@rks972131
May 02 2017 06:22
requiremnts are:- nextInLine([2], 1) should return 2
nextInLine([5,6,7,8,9], 1) should return 5
After nextInLine(testArr, 10), testArr[4] should be
Damien
@DubbDevs
May 02 2017 06:23
@revisualize thank you!!
CamperBot
@camperbot
May 02 2017 06:23
dubbdevs sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3877 | @revisualize |http://www.freecodecamp.com/revisualize
Masaki
@masaki1223
May 02 2017 06:23
@revisualize Thanks for your help.
CamperBot
@camperbot
May 02 2017 06:23
masaki1223 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3878 | @revisualize |http://www.freecodecamp.com/revisualize
rks972131
@rks972131
May 02 2017 06:23
any one is there......
Masaki
@masaki1223
May 02 2017 06:24
@masaki1223 re: myObj.checkProp; ... Dot Notation is converting the value to a string (string literal). Example: myObj.name; is the same as myObj["name"]; and as we all know quotes define strings. If you want to use a variable for accessing the value of object properties you cannot use Dot Notation. You have to use Bracket Notation. Example: var num = 42; myObj[num];
I passed the challenge, but I do not fully understand the difference between accessing prop using variable and dot notation...
Joseph
@revisualize
May 02 2017 06:26
@DubbDevs Ummm.. That's not really what's supposed to happen.

@DubbDevs By doing this: var phoneticLookup = val; result = lookup[phoneticLookup]; ... You're creating a variable that isn't needed.

With this code: function phoneticLookup(val) { } you have a function declaration with a function name of phoneticLookup and a parameter val.
When you make the function call: phoneticLookup("charlie"); You are calling the function by name and passing the argument of "charlie" to the function parameter of val as a value.
You'll need to use bracket notation to access your object (lookup) property value. Note: Parameters are used inside of your function just like variables.
You need to assign the value of the object property to the variable result.
Then when your function phoneticLookup returns result it will return the correct object property value.

So, when you do lookup[val]; you're accessing the lookup with the parameter val that has a value of "charlie" and to get the object property value of "Chicago".
With result = lookup[val]; You're assigning that object property value to the variable result. Then you're returning result.

Damien
@DubbDevs
May 02 2017 06:31
awwwwwwwwwwww ok I'll wipe it out an try again
sooooooo
result = lookup[val];
that's all I needed?!?!
Conor Murphy
@cmurphy580
May 02 2017 06:35
can anyone tell me why this is not being recognized as a function in my constructor?
Cat.averageWeight = function() {
      return Math.ceil(weights/count);
    }
Damien
@DubbDevs
May 02 2017 06:36
no wait that's the wrong one
@revisualize wait it was green so was that all I needed?
Markus Kiili
@Masd925
May 02 2017 06:38
@cmurphy580 If you wan't all the cats to inherit the method, you need to add it into the Cat.prototype object.
naveenmehta
@naveenmehta
May 02 2017 06:39
convert celcsius to fahrenheit...? how to do it
Markus Kiili
@Masd925
May 02 2017 06:40
@cmurphy580 Methods are defined inside the constructor, or added to the prototype.
Nahuel Ovejero
@NahuelOvejero
May 02 2017 06:40
@naveenmehta use the function in the left (in the example)
Conor Murphy
@cmurphy580
May 02 2017 06:40
@Masd925 i just want Cat have it. not the objects it creates.
Markus Kiili
@Masd925
May 02 2017 06:40
@cmurphy580 What is Cat?
naveenmehta
@naveenmehta
May 02 2017 06:41
there is no example, they have just said to apply the algorithm
@NahuelOvejero
Conor Murphy
@cmurphy580
May 02 2017 06:42
@Masd925 here's the whole constructor i have set up with that function

var Cat = (function () {

  var count = 0, weights = 0; 

  return function Cat(name, weight) {

   this.name = name; 
   this.weight = weight; 
   if (!name || !weight) throw TypeError(undefined);

   count++;
   weights += weight;

   Object.defineProperty(this, 'weight', {
      get: function() { 
        return weight; 
      },
      set: function(value) {
        weight = value;
        weights -= weight; 
        weights += value;
      }
    });

    Cat.averageWeight = function() {
      return Math.ceil(weights/count);
    }

} 


})();
rugano
@rugano
May 02 2017 06:43
function mutation(arr) {
   var eleIndexOf = arr;

if('ele1 ele2'.indexOf('ele2) !== -1) {

     return 'ele1 ele2'.indexOf('ele2') !== -1;

  }

}

mutation(["hello", "hey"]);
how do i correct this code?
Nahuel Ovejero
@NahuelOvejero
May 02 2017 06:44
@cmurphy580 T(°F) = T(°C) × 9/5 + 32
so, Celcious * 9/5 + 32
vishnu1207
@vishnu1207
May 02 2017 06:44
can someone help me out with how to convert celcsius to fahrenheit...?
I am not able to get any examples.
Nahuel Ovejero
@NahuelOvejero
May 02 2017 06:45
@vishnu1207 example is the math formula you have to apply