These are chat archives for FreeCodeCamp/HelpJavaScript

2nd
Jun 2017
RonnyNovik
@RonnyNovik
Jun 02 2017 00:03
How can you force an animation?Like a hover animation if you want to prevent it from going insane if you trigger it alot of times
Ryan Nelson
@iamryandnelson
Jun 02 2017 00:09
Does anyone know how I can make it so that my calculator won't accept a decimal if one's already been entered? https://codepen.io/iamryandnelson/pen/JNOvzx?editors=0010
Stephen James
@sjames1958gm
Jun 02 2017 00:11
`return if inputs.indexOf(".") !== -1 and input is "."
@JToddFL Why do you need to loop over obj1Array?
Gulsvi
@gulsvi
Jun 02 2017 00:14
@RonnyNovik You .stop() the previous animation when starting the new one - or disable the element until you get an animationEnd event
It depends on how you're doing your animation
Ryan Nelson
@iamryandnelson
Jun 02 2017 00:15
@sjames1958gm Are you talking to me? :)
Stephen James
@sjames1958gm
Jun 02 2017 00:15
@iamryandnelson Yes :) -
Ryan Nelson
@iamryandnelson
Jun 02 2017 00:16
@sjames1958gm Okay, just checking, lol. Let me try
Stephen James
@sjames1958gm
Jun 02 2017 00:16
@iamryandnelson Use indexOf to search if "." already in the input
the menu
jtanzola
@jtanzola
Jun 02 2017 00:22
how do i make c have a value of I am a string?
Ryan Nelson
@iamryandnelson
Jun 02 2017 00:23
@sjames1958gm Awesome! That works, but now if I want to add a decimal to a number after the operator it won't let me...
Gulsvi
@gulsvi
Jun 02 2017 00:26
@RonnyNovik Very cool animation :) I think it might be easiest to set up a click function for closing the menu in your case...
RonnyNovik
@RonnyNovik
Jun 02 2017 00:27
@SkyC0der You can't force it to end no matter what?
Gulsvi
@gulsvi
Jun 02 2017 00:27
Way too easy to hover off of the menu and cause it to collapse again - and since the animation takes over 3 seconds to complete
Ethan
@ejmarsha
Jun 02 2017 00:27

var count = 0;

function cc(card) {
// Only change code below this line
var Decision="";
switch (card){

case 2:
case 3:
case 4:
case 5:
case 6:
count++;
  break;
case 7:
case 8:
case 9: 
break;
case 10:
  case'J':
  case'Q':
  case'K':
  case'A':
  count--;
  break;

}
switch (count)
{
case 0,-1:
Decision=" Hold";
break;
case 1:
Decision=" Bet";
break;

}

return count+= Decision;

// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(6); cc(4); cc(5);

I'm having trouble adding to global variable count
Gulsvi
@gulsvi
Jun 02 2017 00:28
@RonnyNovik I'm not saying you can't do it - just saying what's easiest. Do you know how to hook up events to your animations?
Ethan
@ejmarsha
Jun 02 2017 00:28

var code="formatted";
var count = 0;

function cc(card) {
// Only change code below this line
var Decision="";
switch (card){

case 2:
case 3:
case 4:
case 5:
case 6:
count++;
  break;
case 7:
case 8:
case 9: 
break;
case 10:
  case'J':
  case'Q':
  case'K':
  case'A':
  count--;
  break;

}
switch (count)
{
case 0,-1:
Decision=" Hold";
break;
case 1:
Decision=" Bet";
break;

}

return count+= Decision;

// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(6); cc(4); cc(5);

RonnyNovik
@RonnyNovik
Jun 02 2017 00:28
@SkyC0der Nope
Gulsvi
@gulsvi
Jun 02 2017 00:28
@RonnyNovik The idea is that you unbind mouseenter events until the animation is complete
Otherwise, this is a simple effective approach:
$(".logomenu").mouseenter(function() {
  $(this).animate({height: "140px",width: "600px",marginLeft: "-300px"},"slow");
  $("nav ul").delay(600).show("clip", { direction: "horizontal" }, 700);
  $("nav li").delay(1000).fadeIn(2000);
});

$('body').click(function() {
  $('.logomenu').animate({height: "80px", width: "200px", marginLeft: "-100px"}, 700);
  $("nav ul").hide("clip", { direction: "horizontal" }, 400);
  $("nav li").fadeOut(100).stop();
});
Peter Kay
@deuscode
Jun 02 2017 00:30
// specify env file path
require('dotenv').config({path: 'keys.env'});
var fetch = require('isomorphic-fetch');
var express = require('express');
var app = express();

var weatherURL = `http://api.openweathermap.org/data/2.5/weather?units=imperial&APPID=${process.env.WEATHER_KEY}`

// console log API Key test
app.get('/weather/:lat:lon', function (req, res) {
    fetch(`${weatherURL}&lat=${req.params.lat},&lon${req.params.lon}`)
        .then(response => response.json())
        .then(weather => res.send(weather))
        .catch(error => res.send(error))
})

// verify server is running
app.listen(3030, function () {
    console.log("I'm alive!");
    console.log(weatherURL);
})
Hey fellow campers, I'm trying to create a backend with node.js and express but I cannot find on a documentation on how to have express take two parameters under app.get('/weather/:lat:lon' --- any suggestions or help would be appreciated!
Ethan
@ejmarsha
Jun 02 2017 00:31

var count = 0;

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

}
switch (count)
{
case 0,-1:
Decision=" Hold";
break;
case 1:
Decision=" Bet";
break;

}

return count+= Decision;

// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(6); cc(4); cc(5);

Stephen James
@sjames1958gm
Jun 02 2017 00:32
@iamryandnelson I guess you could keep the operands in separate variables, and only combine them for display
@ejmarsha You should probably use an if/else for the second part
Wisdom Peters
@blackcytographer
Jun 02 2017 00:32
PLEASE WOT SEEMS TO BE WRONG WITH MY CODE
var myCar = new Car ();
myCar.brand = "toyota";
Stephen James
@sjames1958gm
Jun 02 2017 00:33
@jtanzola You have to initialize c to the first part of the string -
Bharath Kumar Reddy
@reddy-bharathkumar
Jun 02 2017 00:33
str = str.split(' ');
for( var i = 0; i < str.length; i++)
{
str[i][0] = str[i][0].toUpperCase();
}
can anyone help me by explaining what's wrong in this
Stephen James
@sjames1958gm
Jun 02 2017 00:33
@blackcytographer Weren't you supposed to add a nickname not a brand?
Ethan
@ejmarsha
Jun 02 2017 00:34
var code=formatted;
Stephen James
@sjames1958gm
Jun 02 2017 00:34
@reddy-bharathkumar You can't change a letter in a string
Wisdom Peters
@blackcytographer
Jun 02 2017 00:35
@sjames1958gm thanks but cant i use brand as nickname?
CamperBot
@camperbot
Jun 02 2017 00:35
blackcytographer sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7582 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Bharath Kumar Reddy
@reddy-bharathkumar
Jun 02 2017 00:35
@sjames1958gm can you please explain which method do I have to use
Ethan
@ejmarsha
Jun 02 2017 00:35
how can I format code on the display here
Stephen James
@sjames1958gm
Jun 02 2017 00:35
@blackcytographer The property is nickname not the property brand
@reddy-bharathkumar You can rebuild the word from toUpperCase of first letter + remainder of string.
@blackcytographer myCar.nickname = "something"
Wisdom Peters
@blackcytographer
Jun 02 2017 00:36
@sjames1958gm oh i see wasnt reading the questions very well
Ethan
@ejmarsha
Jun 02 2017 00:38
@sjames1958gm thx
CamperBot
@camperbot
Jun 02 2017 00:38
ejmarsha sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7583 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
MordecaiMan
@MordecaiMan
Jun 02 2017 00:40
how can I get the string of something set in an object?
Bharath Kumar Reddy
@reddy-bharathkumar
Jun 02 2017 00:40
not getting anything
MordecaiMan
@MordecaiMan
Jun 02 2017 00:40
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};
Like how do i return "pony"
Ethan
@ejmarsha
Jun 02 2017 00:41

`var count = 0;

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

}
switch (count)
{
case 0,-1:
Decision=" Hold";
break;
case 1:
Decision=" Bet";
break;

}

return count+= Decision;

// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(6); cc(4); cc(5); `

Bharath Kumar Reddy
@reddy-bharathkumar
Jun 02 2017 00:41
@MordecaiMan you have to call Objects property
object.propertyname or object[property]
Ethan
@ejmarsha
Jun 02 2017 00:42
'<var count = 0; function cc(card) { // Only change code below this line var Decision=""; switch (card){ case 2: case 3: case 4: case 5: case 6: count++; break; case 7: case 8:>`
Peter Kay
@deuscode
Jun 02 2017 00:42
app.get('/weather/:lat/:lon', function (req, res) {
    fetch(`${weatherURL}&lat=${req.params.lat}&lon=${req.params.lon}`)
        .then(response => response.json())
        .then(weather => res.send(weather))
        .catch(error => res.send(error))
})
Nevermind, fiddled around and found out that I needed a forward slash... GOLLY LOL
MordecaiMan
@MordecaiMan
Jun 02 2017 00:42
So I would do myObj.gift if I wanted to return "pony" @reddy-bharathkumar
Gulsvi
@gulsvi
Jun 02 2017 00:43
@RonnyNovik This may also work out for you:
 $( ".logomenu" ).mouseenter(function() {
    $(this).stop().animate({height: '140px',width: '600px', marginLeft: '-300px'}, "slow", function() {
       $("nav ul").delay(600).show('clip', { direction: 'horizontal' }, 700);
       $("nav li").delay(1000).fadeIn(2000);
    });
  }).mouseleave(function() {
   $(this).stop().animate({height: '80px',width: '200px',marginLeft: '-100px'}, 700, function() {
     $("nav ul").hide('clip', { direction: 'horizontal' }, 400);;
     $("nav li").fadeOut(100).stop();
   });
  });
MordecaiMan
@MordecaiMan
Jun 02 2017 00:43
or would I do myObj[gift]
That last thing worked
Bharath Kumar Reddy
@reddy-bharathkumar
Jun 02 2017 00:43
@MordecaiMan anything would work
Ethan
@ejmarsha
Jun 02 2017 00:44
```js
var count = 0;
function cc(card) {
// Only change code below this line
var Decision="";
switch (card){
case 2:
case 3:
case 4:
case 5:
case 6:
count++;
break;
case 7:
case 8:
Stephen James
@sjames1958gm
Jun 02 2017 00:44
@reddy-bharathkumar str[i] = str[i][0].toUpperCase() + str[i].slice(1)
@ejmarsha You need ``` at the end on its own line (use shift-enter) to get new line
@MordecaiMan myObj.gift or myObj["gift"]
Ethan
@ejmarsha
Jun 02 2017 00:46
var count = 0; function cc(card) { // Only change code below this line var Decision=""; switch (card){ case 2: case 3: case 4: case 5: case 6: count++; break; case 7: case 8:
Adam Faraj
@adamfaraj
Jun 02 2017 00:46
anyone good with array methods?
having trouble figuring out why my sort() isn't working like i want it too
ryanmiller12
@ryanmiller12
Jun 02 2017 00:46

can someone tell me what i'm doing wrong on this lesson?
every thing calculates except for the last else if statement

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

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

Ethan
@ejmarsha
Jun 02 2017 00:46
`var count = 0;
function cc(card) {
// Only change code below this line
var Decision="";
switch (card){
case 2:
case 3:
case 4:
case 5:
case 6:
count++;
break;
case 7:
case 8:
Stephen James
@sjames1958gm
Jun 02 2017 00:47
@ryanmiller12 You should use === for Bogey and Double Bogey
Manish Giri
@Manish-Giri
Jun 02 2017 00:47
@adamfaraj .sort() needs a function if you want it to sort integers.
Adam Faraj
@adamfaraj
Jun 02 2017 00:47
//jshint esversion: 6

function largestOfFour(arr) {
  var mapped = arr.map((array) => array.sort());
  return mapped;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Manish Giri
@Manish-Giri
Jun 02 2017 00:48
@adamfaraj .sort() needs a function if you want it to sort integers.
Stephen James
@sjames1958gm
Jun 02 2017 00:48
else if (strokes >= par +3) { if this is true then the one before it else if (strokes >= par + 2) { will always be true as well
Manish Giri
@Manish-Giri
Jun 02 2017 00:48
by default, it sorts based on unicode values
Adam Faraj
@adamfaraj
Jun 02 2017 00:48
@Manish-Giri so how do i sort integers of the array?
ryanmiller12
@ryanmiller12
Jun 02 2017 00:48
@sjames1958gm Thanks so much man
CamperBot
@camperbot
Jun 02 2017 00:48
ryanmiller12 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7584 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Adam Faraj
@adamfaraj
Jun 02 2017 00:48
can i change it to utf8 or something?
Manish Giri
@Manish-Giri
Jun 02 2017 00:48
@adamfaraj look out .sort() on MDN
it explains everything
Adam Faraj
@adamfaraj
Jun 02 2017 00:49
@Manish-Giri looking now
ryanmiller12
@ryanmiller12
Jun 02 2017 00:49
also how are you guys posting the code in the nice block?
Adam Faraj
@adamfaraj
Jun 02 2017 00:50
@Manish-Giri
//jshint esversion: 6

function largestOfFour(arr) {
  var mapped = arr.map((array) => array.sort(function(a, b) {
  return a - b;
}));
  return mapped;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
that worked
Manish Giri
@Manish-Giri
Jun 02 2017 00:50
cool
ryanmiller12
@ryanmiller12
Jun 02 2017 00:50
thanks again @sjames1958gm missed the line break
CamperBot
@camperbot
Jun 02 2017 00:50
ryanmiller12 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: ryanmiller12 already gave sjames1958gm points
Adam Faraj
@adamfaraj
Jun 02 2017 00:50
i forgot you needed a function to sort integers
@ryanmiller12 the put ``` before and after code
beside the 1 on your keyboard
thanks @Manish-Giri btw
CamperBot
@camperbot
Jun 02 2017 00:51
adamfaraj sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 5781 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Jun 02 2017 00:51
:+1:
Adam Faraj
@adamfaraj
Jun 02 2017 00:51
@ryanmiller12
code
dang it
code
you get the idea
Bharath Kumar Reddy
@reddy-bharathkumar
Jun 02 2017 00:58
@sjames1958gm thank you
CamperBot
@camperbot
Jun 02 2017 00:58
reddy-bharathkumar sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7585 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
ryanmiller12
@ryanmiller12
Jun 02 2017 00:59
@adamfaraj thanks just forgot the line break after ``` :)
CamperBot
@camperbot
Jun 02 2017 00:59
ryanmiller12 sends brownie points to @adamfaraj :sparkles: :thumbsup: :sparkles:
:cookie: 249 | @adamfaraj |http://www.freecodecamp.com/adamfaraj
Adam Faraj
@adamfaraj
Jun 02 2017 01:02
how do i access the last element of a 2 dimensional array?
so i sorted this:
([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
frederickalcantara
@frederickalcantara
Jun 02 2017 01:03
[0][4][4]
Adam Faraj
@adamfaraj
Jun 02 2017 01:03
so its now reads:
([[1,3,4,5], [13, 18, 26, 27], [32, 35, 37, 39], [1, 857 , 1000, 1001]]);
dyon3334
@dyon3334
Jun 02 2017 01:04
var vs let
Adam Faraj
@adamfaraj
Jun 02 2017 01:04
want i want to do is pop the last element of each inner array
to get 5, 27, 39, 1001
Stephen James
@sjames1958gm
Jun 02 2017 01:06
@adamfaraj If you are doing the map then return the element from the map and voila
@adamfaraj Something like this - reverse the sort and return [0]th element
arr.map((array) => array.sort(function(a, b) {
  return b - a;
})[0]);
Adam Faraj
@adamfaraj
Jun 02 2017 01:10
@sjames1958gm
//jshint esversion: 6

function largestOfFour(arr) {
  var mapped = arr.map((array) => array.sort(function(a, b) {
  return b-a;
}[0]));}


largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Stephen James
@sjames1958gm
Jun 02 2017 01:11
@adamfaraj move one ) to the other side of [0]
@adamfaraj just return the map result - no need for another variable
Adam Faraj
@adamfaraj
Jun 02 2017 01:11
@sjames1958gm it worked!
//jshint esversion: 6

function largestOfFour(arr) {
  return arr.map((array) => array.sort(function(a, b) {
  return b-a;
})[0]);}


largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
thanks @sjames1958gm
CamperBot
@camperbot
Jun 02 2017 01:12
adamfaraj sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7586 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Adam Faraj
@adamfaraj
Jun 02 2017 01:12
so i had a-b and didn't have the that [0]
could you explain why my version didnt work
Stephen James
@sjames1958gm
Jun 02 2017 01:14
@adamfaraj Your version sorted from smallest to largest so you could have done [3]
But that seems a bit hardcoded. So reversing the sort, the largest was at the beginning.
The [0] just did the step that you hadn't solved yet
Adam Faraj
@adamfaraj
Jun 02 2017 01:15
what does adding that [0] do though?
i'm with up until the [0]
i'm with you*
Stephen James
@sjames1958gm
Jun 02 2017 01:17

@adamfaraj

array.sort(function(a, b) {
  return b-a;
})

this returns an array [0] added to it results in the first element of the sorted array.
Equivalent to:

array.sort(function(a, b) {
  return b-a;
})
return array[0]
Adam Faraj
@adamfaraj
Jun 02 2017 01:20
so doing array[0] is just sort of like unshifting the results of the function (a,b) { return b-a; })?
Stephen James
@sjames1958gm
Jun 02 2017 01:20
@adamfaraj basically.
Adam Faraj
@adamfaraj
Jun 02 2017 01:21
ahhhhhh, ok ok. i'm with you
Stephen James
@sjames1958gm
Jun 02 2017 01:21
@adamfaraj :+1:
Greg Duncan
@GregatGit
Jun 02 2017 01:22
@adamfaraj you can also use Math.max - it takes in numbers and returns the highest value
WillGITCode
@WillGITCode
Jun 02 2017 01:23
Im stuck on No repeats please. I think I understand Heap's algorithm but I only get four arrays when I expect 6. None of them have had letters swapped. And if I try to write my for loop with i<n instead of i<n-1 it crashes the browser.
any ideas?
function permAlone(str) {
 if(str.length === 1){
   return 1;
  } 
  var arr = [];
  var strCopy = str.split("");

  var heaps = function(a, n){
     for(var i=0;i<n-1;i++){
       heaps(a,n-1);
       if(n%2===0){
         hotSwap(a,i,n-1);
         arr.push(a);
       }else{
         hotSwap(a,0,n-1);
         arr.push(a);
       }
    }
  };

  function hotSwap(a,firstPos, lastPos){
    var temp = a[firstPos];
    a[firstPos] = a[lastPos];
    a[lastPos] = temp;
  }

  heaps(strCopy,strCopy.length);

  return arr;
}

permAlone('aab');
Greg Duncan
@GregatGit
Jun 02 2017 01:23
@adamfaraj you have to use the es6 spread operator Math.max(...arr)
Adam Faraj
@adamfaraj
Jun 02 2017 01:23
@GregatGit thanks man
CamperBot
@camperbot
Jun 02 2017 01:23
adamfaraj sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:cookie: 857 | @gregatgit |http://www.freecodecamp.com/gregatgit
Greg Duncan
@GregatGit
Jun 02 2017 01:25
@WillGITCode what is the challenged called?
WillGITCode
@WillGITCode
Jun 02 2017 01:26
@GregatGit No repeats please
Greg Duncan
@GregatGit
Jun 02 2017 01:33
@WillGITCode when I coded this I set up a counter and then build a recursive function - it would build the string and if came to a double letter it would break and if it got to the end it would count++
@WillGITCode it would never save the string - only count that it had done it -
@WillGITCode during testing we would push the string to array just before counting to see what it was counting - but removed that part as it wasn't really needed
WillGITCode
@WillGITCode
Jun 02 2017 01:36
I was planning on doing something similar. I just wanted to verify that i can generate permutations properly. which my results show that I am not currently doing.
xyzruben
@xyzruben
Jun 02 2017 01:37
Hello I need help with the "Word Blanks" game. I'm not sure how to get started.
Could any one give me a hint? Thanks
Joseph
@Big-jo
Jun 02 2017 01:38
@xyzruben yes
xyzruben
@xyzruben
Jun 02 2017 01:38

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

// Your code above this line
return result;
}

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

WillGITCode
@WillGITCode
Jun 02 2017 01:38
@GregatGit Im really confused about the for loop crashing chrome. even if I hard code a small number of iterations it says maximum call stack exceeded.
Greg Duncan
@GregatGit
Jun 02 2017 01:39
@WillGITCode for readability I would space it out more hotSwap(a,i,n-1); should be hotSwap(a, i, n-1);
Joseph
@Big-jo
Jun 02 2017 01:39
concatenate them e.g result="myNoun is,"+myAdjective
concatenate them e.g result="myNoun is,"+myAdjective @xyzruben
Greg Duncan
@GregatGit
Jun 02 2017 01:40
@WillGITCode that just means you have created an infinite loop that keeps using more and more memory
@WillGITCode before it can get remove code from memory your code has added to it
be very careful about putting recursive funtions in forloops
xyzruben
@xyzruben
Jun 02 2017 01:48

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
"I have a " + myNoun + "named Tona."

// Your code above this line
return result;
}

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

Please help guys with the "Word Blanks" game
I'm not sure how to begin
Joseph
@Big-jo
Jun 02 2017 01:49
@xyzruben i just showed you
@xyzruben i'll write the code
xyzruben
@xyzruben
Jun 02 2017 01:50
@Big-jo sorry i lost it
could you please repeat
Joseph
@Big-jo
Jun 02 2017 01:50
concatenate them e.g result="myNoun is,"+myAdjective @xyzruben
make sure you add some of your own words with comma's
xyzruben
@xyzruben
Jun 02 2017 01:52
So the purpose is to use all the word blanks in a sentence/phrase?
Ogechi Ike
@BlackMG27
Jun 02 2017 01:53
Hello! I'm having some trouble with Nesting For Loops. Thanks in advance.
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  for(var i = 0; i < multiplyAll.length; i++){
    for(var j = 0; j < multiplyAll[i].length; j++){
      product = product * arr[i][j];
    }
  }
  // Only change code above this line
  return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
Hassan McCutchen
@hmccutchen
Jun 02 2017 01:53
@xyzruben specifically I'd say to add words BETWEEN each variable. (they haven't yet taught how to create spaces within the strings yet)
Joseph
@Big-jo
Jun 02 2017 01:53
result = "my " + myNoun + " is very " + myAdjective + ", so he ran" + myAdverb
@xyzruben
Farmerwan
@muntanui
Jun 02 2017 01:54
How do I copy my code window to a message here, please?
Joseph
@Big-jo
Jun 02 2017 01:54
@xyzruben sorry i didnt complete it but it's basically like that
xyzruben
@xyzruben
Jun 02 2017 01:55
oh i see @Big-jo
Greg Duncan
@GregatGit
Jun 02 2017 01:55
@muntanui ``` on a seperate line before and after your code
Joseph
@Big-jo
Jun 02 2017 01:55
@muntanui just use 3 backticks and the language you want, then enter
Greg Duncan
@GregatGit
Jun 02 2017 01:55
@muntanui not '''
CamperBot
@camperbot
Jun 02 2017 01:55
:bulb: to format code use backticks! ``` more info
Farmerwan
@muntanui
Jun 02 2017 01:55
Thanks all!
xyzruben
@xyzruben
Jun 02 2017 01:55
@Big-jo @hmccutchen Thanks guys! I think i get it now
CamperBot
@camperbot
Jun 02 2017 01:55
xyzruben sends brownie points to @big-jo and @hmccutchen :sparkles: :thumbsup: :sparkles:
:cookie: 157 | @hmccutchen |http://www.freecodecamp.com/hmccutchen
:cookie: 168 | @big-jo |http://www.freecodecamp.com/big-jo
Jeremy
@JeremyAntonoff
Jun 02 2017 01:55
can anyone help
Joseph
@Big-jo
Jun 02 2017 01:56
@xyzruben :+1:
@JToddFL what's your question
Farmerwan
@muntanui
Jun 02 2017 01:57

Having trouble with the Card Counting, here's my code:
```var count = 0;

function cc(card) {
// Only change code below this line
var decision = "";
switch (card) {
case 2:
case 3:
case 4:
case 5:
case 6:
count++;
break;
case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
count--;
break;
}
switch (decision) {
case count > 0:
console.log(count," Bet");
break;
case count < 0:
console.log(count, " Hold");
break;
}

// Only change code above this line
}

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

Any help appreciated

Jeremy
@JeremyAntonoff
Jun 02 2017 01:57
@Big-jo I'm trying to add a key from object two that is not found in object one
function extend(obj1, obj2) {
  // your code here
  var obj1Array = Object.keys(obj1);
  var obj2Array = Object.keys(obj2);
  for (var i =0; i < obj1Array.length; i++) {
    for (var j=0; j <obj2Array.length; j++) {
      if (obj1Array[i] !== obj2Array[j]) {
        obj1[obj2Array[j]] == obj2[obj2Array[j]];
      }
    }
}
return obj1
}
extend({
  a: 1,
  b: 2
},
{
  b: 4,
  c: 3
})
Joseph
@Big-jo
Jun 02 2017 01:59
@GregatGit
function extend(obj1, obj2) {
  // your code here
  var obj1Array = Object.keys(obj1);
  var obj2Array = Object.keys(obj2);
  for (var i =0; i < obj1Array.length; i++) {
    for (var j=0; j <obj2Array.length; j++) {
      if (obj1Array[i] !== obj2Array[j]) {
        obj1[obj2Array[j]] == obj2[obj2Array[j]];
      }
    }
}
return obj1
}
extend({
  a: 1,
  b: 2
},
{
  b: 4,
  c: 3
})
Manish Giri
@Manish-Giri
Jun 02 2017 01:59
@muntanui replace this
switch (decision) {
case count > 0:
console.log(count," Bet");
break;
case count < 0:
console.log(count, " Hold");
break;
}
with an if/else
Ogechi Ike
@BlackMG27
Jun 02 2017 01:59
@muntanui Try using an if/else statement for the count 7,8,9 cases instead of a switch statement.
Greg Duncan
@GregatGit
Jun 02 2017 02:00
@JToddFL don't use the word extend - it is reserved
Farmerwan
@muntanui
Jun 02 2017 02:01
@Manish-Giri and @BlackMG27 thanks, I'll give that a try
CamperBot
@camperbot
Jun 02 2017 02:01
muntanui sends brownie points to @manish-giri and @blackmg27 :sparkles: :thumbsup: :sparkles:
:cookie: 174 | @blackmg27 |http://www.freecodecamp.com/blackmg27
:star2: 5786 | @manish-giri |http://www.freecodecamp.com/manish-giri
Jeremy
@JeremyAntonoff
Jun 02 2017 02:01
@GregatGit thats the function that was given to me
its not my code
@sjames1958gm to see if a key in object 1 matches one in object 2
Greg Duncan
@GregatGit
Jun 02 2017 02:05
@JToddFL so you want to add c: 3 to ojb 1?
Jeremy
@JeremyAntonoff
Jun 02 2017 02:06
@GregatGit yes. if i was to pass other keys into object 2 that werent present in object 1 those would get added as well
Greg Duncan
@GregatGit
Jun 02 2017 02:07
@JToddFL you don't need to get the Object.keys of the object you want to add to
Jeremy
@JeremyAntonoff
Jun 02 2017 02:08
@GregatGit admittedly I'm bad at objects. why would that be the case?
doesnt it need to check to see if its there
Greg Duncan
@GregatGit
Jun 02 2017 02:08
@GregatGit just the first one, the you could use hasOwnProperty()
@JToddFL you don't need to get the keys to check if it has that property
just use hasOwnProperty()
Jeremy
@JeremyAntonoff
Jun 02 2017 02:09
does it need two for loops to loop through
or could I just do hasOwnProperty(i) === obj2array[i]
Greg Duncan
@GregatGit
Jun 02 2017 02:11
@JToddFL no - just one loop
Jeremy
@JeremyAntonoff
Jun 02 2017 02:12
ok let me try again hold on. Thanks man
Greg Duncan
@GregatGit
Jun 02 2017 02:12
@JToddFL obj.hasOwnProperty(prop) this return true of false -
wes adams
@wes-adams
Jun 02 2017 02:12
anyone tell me the correct way to post code for a question?
Greg Duncan
@GregatGit
Jun 02 2017 02:13
if true move on - if false add the property @JToddFL
@JToddFL objYouWantToAddTo.hasOwnProperty(obj2Array[i])
wes adams
@wes-adams
Jun 02 2017 02:15
i'll wing it and see what happens.
Ellyria
@Ellyria
Jun 02 2017 02:15
This should help, @wes-adams:
'''
CamperBot
@camperbot
Jun 02 2017 02:15
:bulb: to format code use backticks! ``` more info
Jeremy
@JeremyAntonoff
Jun 02 2017 02:15
@GregatGit am i close with this
function extend(obj1, obj2) {
  // your code here
  var obj1Array = Object.keys(obj1);
  var obj2Array = Object.keys(obj2);
  for (var i =0; i < obj1Array.length; i++) {
    if (obj1.hasOwnProperty([obj2Array[i]] === false)) {
      obj1[obj2Array[i]] = obj2Array[i];
    }

}
return obj1
}
wes adams
@wes-adams
Jun 02 2017 02:16
thanks! @camperbot
CamperBot
@camperbot
Jun 02 2017 02:16
wes-adams sends brownie points to @camperbot :sparkles: :thumbsup: :sparkles:
:star2: 3282 | @camperbot |http://www.freecodecamp.com/camperbot
wes adams
@wes-adams
Jun 02 2017 02:16
lemme try
Greg Duncan
@GregatGit
Jun 02 2017 02:17
@JToddFL you only need the keys of obj2 -
Juriel Garcia
@Garciaj007
Jun 02 2017 02:17
Hello, is there something wrong with str = String.fromCharCode(str);?
wes adams
@wes-adams
Jun 02 2017 02:17
var testing;
Jeremy
@JeremyAntonoff
Jun 02 2017 02:18
@GregatGit I know just didnt delete it. I dont use it in my for loop
function extend(obj1, obj2) {
  // your code here
  var obj2Array = Object.keys(obj2);
  for (var i =0; i < obj1Array.length; i++) {
    if (obj1.hasOwnProperty([obj2Array[i]] === false)) {
      obj1[obj2Array[i]] = obj2Array[i];
    }

}
return obj1
}
Name Name, Jr.
@f1ux1uxday
Jun 02 2017 02:19
why am i unable to return the value of newString in the following code?
wes adams
@wes-adams
Jun 02 2017 02:19

//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUpProfile(firstName, prop){
// Only change code below this line
var i,j;
var text = "";
text = prop;
for(i=0; i<contacts.length; i++){
  if(contacts[i].firstName == firstName){
    if(contacts[i].prop == prop){
      return contacts[i].prop;
    }
        //return contacts[i][j];
        //r/eturn "prop";
    //return "First name found!";
  }
  //else return "No such contact";
}
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Greg Duncan
@GregatGit
Jun 02 2017 02:19
@JToddFL for (var i =0; i < obj1Array.length; i++) { this is wrong
wes adams
@wes-adams
Jun 02 2017 02:19
i'm stumped on this iteration problem
i don't know how to access
Jeremy
@JeremyAntonoff
Jun 02 2017 02:20
I just realized that lol
I changed it to obj2Array
wes adams
@wes-adams
Jun 02 2017 02:20
the inner items inside the array
Greg Duncan
@GregatGit
Jun 02 2017 02:20
@JToddFL there is no obj1Array
Jeremy
@JeremyAntonoff
Jun 02 2017 02:20
still not adding the C: 2 though
function extend(obj1, obj2) {
  // your code here
  var obj2Array = Object.keys(obj2);
  for (var i =0; i < obj2Array.length; i++) {
    if (obj1.hasOwnProperty([obj2Array[i]] === false)) {
      obj1[obj2Array[i]] = obj2Array[i];
    }

}
wes adams
@wes-adams
Jun 02 2017 02:21
'contacts[i].prop == prop;' i don't know what i'm doing wrong on this line
Ellyria
@Ellyria
Jun 02 2017 02:22
What is the value of str before that line, @Garciaj007?
wes adams
@wes-adams
Jun 02 2017 02:22
contacts[i].prop == prop; i don't know what i'm doing wrong on this line
Juriel Garcia
@Garciaj007
Jun 02 2017 02:22
@Ellyria a bunch of numbers
seperated by a comma
Ellyria
@Ellyria
Jun 02 2017 02:23
Jeremy
@JeremyAntonoff
Jun 02 2017 02:24
@GregatGit I figured out how to add the C
I just cant figure out how to add the 2
Juriel Garcia
@Garciaj007
Jun 02 2017 02:25
@Ellyria I may have over complicated the code but heres what I got
function binaryAgent(str) {
  var decimal = [128, 64, 32, 16, 8, 4, 2, 1];
  str = str.split(" ");
  for(var i = 0; i < str.length; i++){
    str[i] = str[i].split("");
    for(var j = 0; j < str[i].length; j++){
      if (str[i][j] === "1"){
        str[i][j] = decimal[j];
      } else if (str[i][j] === "0"){
        str[i][j] = 0;
      }
    }
    str[i] = str[i].reduce(function(a,b){
      return a + b;
    });  
  }

  str = str.join(",");
  //str = String.fromCharCode(str);
  return str;
}
@Ellyria the part that is commented out is what i'm converting to a string
Greg Duncan
@GregatGit
Jun 02 2017 02:32
@JToddFL you made a small error here obj1[obj2Array[i]] = obj2Array[i]; it should not equal obj2Array[i]
Joseph
@Big-jo
Jun 02 2017 02:33
how do i add an array to a function as an argument
Ellyria
@Ellyria
Jun 02 2017 02:34
I'm not sure, @Garciaj007. If I uncomment it and add console.log(str); on the line after it, I get one of those waffle characters that represent an unknown character. I've never seen that in the console before. What do you get?
functionname(arrayname);
Wait. I might be wrong. That might be functionname([arrayname]); instead.
Henry
@GitHub-Henry
Jun 02 2017 02:35
CamperBot
@camperbot
Jun 02 2017 02:35
@GitHub-Henry :8ball: it is certain :sparkles:
Greg Duncan
@GregatGit
Jun 02 2017 02:35
@Big-jo are you building the function or using someone elses?
Joseph
@Big-jo
Jun 02 2017 02:36
@GregatGit using the fcc one
Robert Arifin
@renkachan
Jun 02 2017 02:36
@Ellyria this is it what i came out, maybe can act as reference.
function binaryAgent(str) {
  var n = 7;
  var stringCombiner =  "";
  var binaryCal = 0;
  var count = 0;
 for (var i = 0; i < str.length; i++)  { 
  if ( str.charCodeAt(i) !== 32)  {
     binaryCal = binaryCal + (str.charAt(i) * Math.pow(2,n));
     count++;
     n--;
   }
   if (count == 8)  {
     stringCombiner = stringCombiner + String.fromCharCode(binaryCal);
     binaryCal = 0;
     n = 7;
     count = 0;
   }

 }
 return stringCombiner;  
}
Joseph
@Big-jo
Jun 02 2017 02:36
the stand inline challenge @GregatGit
Greg Duncan
@GregatGit
Jun 02 2017 02:38
@Big-jo normally you use arr here is mine function nextInLine(arr, item)
wes adams
@wes-adams
Jun 02 2017 02:38
Okay, i'm totally stumped guys. I cannot figure out how to iterate through an array of objects. At this point, i think its nothing more than a syntax error, but i don't know how to fix it.
Okay, i'm totally stumped guys. I cannot figure out how to iterate through an array of objects. At this point, i think its nothing more than a syntax error, but i don't know how to fix it.

//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


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

// Change these values to test your function
lookUpProfile("Akira", "likes");
Greg Duncan
@GregatGit
Jun 02 2017 02:39
@Big-jo you can be more descriptive if needed but always tray to use arr in somewhere like gameArr usedNumArr
Moisés Man
@moigithub
Jun 02 2017 02:39
@wes-adams u only need 1 loop to iterate the contacts array
contacts[i] is an object
Greg Duncan
@GregatGit
Jun 02 2017 02:40
@wes-adams you don't need the 2nd forloop
Joseph
@Big-jo
Jun 02 2017 02:40

function 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, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
@GregatGit i did this and it's only partially working
Greg Duncan
@GregatGit
Jun 02 2017 02:40
@wes-adams
function lookUpProfile(firstname, prop){
// Only change code below this line
var i,j;
for(i=0; i<contacts.length; i++){
  if(contacts[i].firstName == firstname){

    }
  }
}
// Only change code above this line
}
wes adams
@wes-adams
Jun 02 2017 02:41
how do i parse the items inside the object?
Moisés Man
@moigithub
Jun 02 2017 02:41
read the helpful links @wes-adams
Juriel Garcia
@Garciaj007
Jun 02 2017 02:41
@Ellyria Honestly I get nothing when i console.log(str);
I also get this wierd red dot in the main console on fcc
wes adams
@wes-adams
Jun 02 2017 02:42
@moigithub @GregatGit thanks guys. i'll keep at it.
CamperBot
@camperbot
Jun 02 2017 02:42
wes-adams sends brownie points to @moigithub and @gregatgit :sparkles: :thumbsup: :sparkles:
:cookie: 858 | @gregatgit |http://www.freecodecamp.com/gregatgit
:star2: 3298 | @moigithub |http://www.freecodecamp.com/moigithub
Juriel Garcia
@Garciaj007
Jun 02 2017 02:42
image.png
Greg Duncan
@GregatGit
Jun 02 2017 02:42
@wes-adams At this stage you know they have the right firstname - use hasOwnProperty to check if it has the prop
Moisés Man
@moigithub
Jun 02 2017 02:42
@Big-jo most methods gets an input then do something and return a result
soo check what shift does.. and what result it return
Juriel Garcia
@Garciaj007
Jun 02 2017 02:43
@Ellyria I think it might be a bug
Joseph
@Big-jo
Jun 02 2017 02:43
@moigithub okay thanks
CamperBot
@camperbot
Jun 02 2017 02:43
big-jo sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3299 | @moigithub |http://www.freecodecamp.com/moigithub
Ellyria
@Ellyria
Jun 02 2017 02:43
Which challenge is that, @Garciaj007?
Juriel Garcia
@Garciaj007
Jun 02 2017 02:44
binary agents @Ellyria
Joseph
@Big-jo
Jun 02 2017 02:44
@moigithub i got it, i was supposed to assign item to the what was shifted.
Moisés Man
@moigithub
Jun 02 2017 02:45
:+1:
Ellyria
@Ellyria
Jun 02 2017 02:45
Ah, you're way ahead of me, @Garciaj007, so I can't even check how I did it.
Moisés Man
@moigithub
Jun 02 2017 02:46
@Garciaj007 join return a string
BUT String.fromCharCode dont work with strings
it only works with number(s) separated by comma
ie: String.fromCharCode(66) // "B"
String.fromCharCode(65,66) // "AB"
ur code doing this String.fromCharCode("65,66") <-- notice the quotes
Robert Arifin
@renkachan
Jun 02 2017 02:46
anyone here that can i ask pointer for symmetric difference question?
Ellyria
@Ellyria
Jun 02 2017 02:46
You have a lot going on with all that code, though, @Garciaj007, and usually the solutions are smaller than that, if it helps any.
That waffle character in the console log is very cool, though.
I've never heard of it, @renkachan.
Nick Forlivio
@whackdev
Jun 02 2017 02:47
I can't figure out why this is returning true, I've checked all the criteria and get the expected response but when I fail the last test
function truthCheck(collection, pre) {

  var times = collection.length;
  var bad = [0, null, false, NaN, '', undefined];


  for (var count=0; count < times; count++) {


    if (collection[count].hasOwnProperty(pre)) {

      if (bad.indexOf(collection[count][pre]) !== -1) {
        return false;
      }

    } else {

        return false;
    }
  }

  return true;
}
truthCheck([{"single": "double"}, {"single": NaN}], "single");
this one
my head already want to explode lol
Moisés Man
@moigithub
Jun 02 2017 02:49
@renkachan i suppose u already did diff 2 arrrays challenge
sym diff is the same...
(a-b) - c
Ellyria
@Ellyria
Jun 02 2017 02:49
It looks like the !== -1 is unnecessary, @whackdev, since the test succeeds without it.
Juriel Garcia
@Garciaj007
Jun 02 2017 02:51
@moigithub thanks didnt realize till now
CamperBot
@camperbot
Jun 02 2017 02:51
garciaj007 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3300 | @moigithub |http://www.freecodecamp.com/moigithub
Ellyria
@Ellyria
Jun 02 2017 02:52
I haven't done that yet, @renkachan, but from looking at it, I'd probably do spaghetti code by creating a third array that contains what they both have in common and then use that to filter the other two arrays. But then I'm not known for coding elegance.
Robert Arifin
@renkachan
Jun 02 2017 02:53
@Ellyria this is what i came out
function sym(args) {
  var newArray = arguments[0];
  var symmetric = [];
  var removingSameElement = [];
  var count = 0;
  for ( var i =1; i < arguments.length; i++)  {
    var testing = newArray.concat(arguments[i]);
  console.log(symmetric);
   for ( var j = 0; j < testing.length; j++)  {
     for (var k = 0; k < testing.length;k++)  {
     if (testing[j] !== testing[k])  {
       count++;
     }  
     }
     if ( count == testing.length-1 && symmetric.indexOf(testing[j]) == -1)  {
       symmetric.push(testing[j]);
    //console.log(symmetric);
     }
    count = 0;
   }
   newArray = symmetric; 
   symmetric = [];
  }
  return newArray;
}
Ellyria
@Ellyria
Jun 02 2017 02:54
Ack, I don't want to look! I haven't done it yet, and I don't want to cheat. Sorry!
Robert Arifin
@renkachan
Jun 02 2017 02:54
LOL
ok
its wrong though
Netrunner21
@Netrunner21
Jun 02 2017 02:54
@renkachan It's beena while since I did that one
I can tell you that you're way over thinking it with your loops and variables
Scratch that
Robert Arifin
@renkachan
Jun 02 2017 02:55
@Netrunner12 yeah, any hint? I also not sure about that solution. should be 2 for loop max
Moisés Man
@moigithub
Jun 02 2017 02:55
[NaN].indexOf(NaN) result -1
@whackdev
Netrunner21
@Netrunner21
Jun 02 2017 02:56
@renkachan I thought you were on record collection/profile lookup
my bad lol
Robert Arifin
@renkachan
Jun 02 2017 02:56
@Netrunner21 lol ,its ok
Ken Haduch
@khaduch
Jun 02 2017 02:58
@whackdev - have you taken a look at Array.filter()? They suggest that in the "helpful links"
Nick Forlivio
@whackdev
Jun 02 2017 02:58
@moigithub yeah thanks i figured it out fixed it with !collection[count][pre]
CamperBot
@camperbot
Jun 02 2017 02:58
whackdev sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3301 | @moigithub |http://www.freecodecamp.com/moigithub
Nick Forlivio
@whackdev
Jun 02 2017 02:58
@khaduch forgot I could use boolean expression instead of array
Nathan
@clarken1996
Jun 02 2017 03:01
Hey guys did I miss something because I have no idea how to this or maybe I am just reading it wrong ?
You will need to use string operators to build a new string, result, using the provided variables: myNoun, myAdjective, myVerb, and myAdverb.
Moisés Man
@moigithub
Jun 02 2017 03:07
@clarken1996 review string concatenation with variables exercise...
u need to build and return a phrase from the words "contained" in those variables
130mk
@130mk
Jun 02 2017 03:09
could anyone help with escape sequences in strings
Nathan
@clarken1996
Jun 02 2017 03:11
@moigithub just realised I was reading it wrong, thanks anyway :shipit:
CamperBot
@camperbot
Jun 02 2017 03:11
clarken1996 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3302 | @moigithub |http://www.freecodecamp.com/moigithub
BradyJ27
@BradyJ27
Jun 02 2017 03:27
Hey guys I need some help with this lesson. I have no idea what to do.
You will need to use string operators to build a new string, result, using the provided variables: myNoun, myAdjective, myVerb, and myAdverb.
Claudio Restifo
@Marmiz
Jun 02 2017 03:34
@BradyJ27 write a function that "adds" those arguments to form a new string:
var str = ''
function example (camperName, camperAdjective) {
return str = camperName + "is" + camperAdjective
}
example('Brady', 'awesome') // "Brady is awesome"
Joseph
@Big-jo
Jun 02 2017 03:35

@BradyJ27

result = "my " + myNoun + " is very " + myAdjective + ", so he ran" + myAdverb +  "and" + myVerb + "again.";

@xyzruben

Ian Arsenault
@ianarsenault
Jun 02 2017 03:36
Anyone implement https on a personal site at all? If so could you recommend how/what you used to do so
Claudio Restifo
@Marmiz
Jun 02 2017 03:37
@GorgonsMaze is it for a "real" project or is for study/hobby?
BradyJ27
@BradyJ27
Jun 02 2017 03:39
@Big-jo how do I finish it? I'm having issues with the semi colon apparently
Joseph
@Big-jo
Jun 02 2017 03:40
@BradyJ27 just make sure it forms some sentence put in some commas and your own words
BradyJ27
@BradyJ27
Jun 02 2017 03:41
@Big-jo Thanks. I was just missing a period
CamperBot
@camperbot
Jun 02 2017 03:41
bradyj27 sends brownie points to @big-jo :sparkles: :thumbsup: :sparkles:
:cookie: 192 | @big-jo |http://www.freecodecamp.com/big-jo
Joseph
@Big-jo
Jun 02 2017 03:42

@BradyJ27

result = "my " + myNoun + " is very " + myAdjective + ", so he ran" + myAdverb +  "and" + myVerb + "again.";

@xyzruben

Sridevi2014
@Sridevi2014
Jun 02 2017 03:42

How can I solve this function myLocalScope() {
'use strict';

var myvar = "use strict";
console.log(myvar);
}
myLocalScope();

// Run and check the console
// myVar is not defined outside of myLocalScope
console.log(myvar);

Joseph
@Big-jo
Jun 02 2017 03:42
@Sridevi2014
Sridevi2014
@Sridevi2014
Jun 02 2017 03:42
error ---Add a local myVar variable
Joseph
@Big-jo
Jun 02 2017 03:43
@Sridevi2014 myVar = 'use strict'
first one should be removed
Sridevi2014
@Sridevi2014
Jun 02 2017 03:44
same error Add a local myVar variable
I tried it
Joseph
@Big-jo
Jun 02 2017 03:45
then remove the console.log() at the bottom
Joseph
@Big-jo
Jun 02 2017 03:45
then remove the console.log() at the bottom @Sridevi2014
Sridevi2014
@Sridevi2014
Jun 02 2017 03:47
I did that
no change

function myLocalScope() {
'use strict';

myVar = 'use strict';

console.log(myvar);
}
myLocalScope();

Joseph
@Big-jo
Jun 02 2017 03:48
How can I solve this function myLocalScope() {



   var myvar = "use strict";
  console.log(myvar);
}
myLocalScope();

// Run and check the console
// myVar is not defined outside of myLocalScope
Jeremy
@JeremyAntonoff
Jun 02 2017 03:48
can someone help me understand an easy concept
Joseph
@Big-jo
Jun 02 2017 03:50

```js
myLocalScope() {

var myVar = "use strict";
console.log(myVar);
}
myLocalScope();

// Run and check the console
// myVar is not defined outside of myLocalScope
``` @Sridevi2014

Adam Faraj
@adamfaraj
Jun 02 2017 03:50
I dont understand what i'm doing wrong
Check if a string (first argument, str) ends with the given target string (second argument, target).

function confirmEnding(str, target) {
 var strEnd = str.substring(str.length - 1);
 var targetEnd = target.substring(target.length -1);
  return targetEnd == strEnd;
}

confirmEnding("Bastian", "n");
im
Jeremy
@JeremyAntonoff
Jun 02 2017 03:50
 var newArray = ['a','b','c']
  var newArray2 = ['a','b','c']
  newArray = newArray.splice(1,1);
  newArray2.splice(1,1)
  return newArray;
  return newArray2;
Adam Faraj
@adamfaraj
Jun 02 2017 03:50
i'm getting all of them right except
confirmEnding("Walking on water and developing software from a specification are easy if both are frozen", "specification") should return false.
Jeremy
@JeremyAntonoff
Jun 02 2017 03:51
why do those splices do two different things
Claudio Restifo
@Marmiz
Jun 02 2017 03:51
@Lwave you should change the result value. So far the function is returning an empty string
Joseph
@Big-jo
Jun 02 2017 03:51
@Sridevi2014 reset your code a redo it properly
Adam Faraj
@adamfaraj
Jun 02 2017 03:52
don't forget the semi-colon after newArray2.splice(1,1)
Moisés Man
@moigithub
Jun 02 2017 03:53
@JToddFL first splice.. remove "b" then it assigning that "b" to newArray
splice also mutates the array
Claudio Restifo
@Marmiz
Jun 02 2017 03:53
@JToddFL because splice return the deleted elements.
Jeremy
@JeremyAntonoff
Jun 02 2017 03:53
@moigithub i know that code is doing different things i mean if i delete one or the other
why do they do different things
Claudio Restifo
@Marmiz
Jun 02 2017 03:53

so with this:

 newArray = newArray.splice(1,1);

you are saving the deleted element

Jeremy
@JeremyAntonoff
Jun 02 2017 03:53
i mean
why does this
var newArray = ['a','b','c']
  var newArray2 = ['a','b','c']
  newArray = newArray.splice(1,1);
differnet then
var newArray = ['a','b','c']
  var newArray2 = ['a','b','c']
  newArray2.splice(1,1)
lesleywayne
@Lwave
Jun 02 2017 03:54
@Marmiz to?
Claudio Restifo
@Marmiz
Jun 02 2017 03:54
@JToddFL
  newArray = newArray.splice(1,1); // assign newArray to the returned value of splice --> the discarded elements
  newArray2.splice(1,1) // keeps the array after removing the discarded elements
Jeremy
@JeremyAntonoff
Jun 02 2017 03:55
makes so much since
@Marmiz thank you
CamperBot
@camperbot
Jun 02 2017 03:55
jtoddfl sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
:cookie: 921 | @marmiz |http://www.freecodecamp.com/marmiz
Claudio Restifo
@Marmiz
Jun 02 2017 03:55
@Lwave the value inside lookup
@JToddFL :+1:
Jeremy
@JeremyAntonoff
Jun 02 2017 03:56
@Marmiz and slice you always use as var x = x.slice?
Claudio Restifo
@Marmiz
Jun 02 2017 03:56
doscumentation is your friend
Netrunner21
@Netrunner21
Jun 02 2017 03:56
Can someone explain what .map() actually does. I've gone through five projects, and the basic and intermediate algorithms, but I'm not sure how to use it. I've seen others use it a lot. Just curious what it can be used for. The documentation isn't really helping.
Sridevi2014
@Sridevi2014
Jun 02 2017 03:56

function myLocalScope() {
'use strict';

console.log(myVar);
}
myLocalScope();

// Run and check the console
// myVar is not defined outside of myLocalScope
console.log(myVar);

Instructions
Declare a local variable myVar inside myLocalScope. Run the tests and then follow the instructions commented out in the editor
Moisés Man
@moigithub
Jun 02 2017 03:56
a=1
a=2 <-- by reassigning values.. previous value get LOST @JToddFL
Claudio Restifo
@Marmiz
Jun 02 2017 03:56
@JToddFL that's because s;ice return a copy of the portion of the array and don't change the original
Sridevi2014
@Sridevi2014
Jun 02 2017 03:57
/ Run and check the console
// myVar is not defined outside o
Jeremy
@JeremyAntonoff
Jun 02 2017 03:57
@marmiz thank you sir
CamperBot
@camperbot
Jun 02 2017 03:57
jtoddfl sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
:warning: jtoddfl already gave marmiz points
Sridevi2014
@Sridevi2014
Jun 02 2017 03:57
/ Now remove the console log line to pass the test
Jeremy
@JeremyAntonoff
Jun 02 2017 03:57
@Netrunner21 would be interested in that question also. Half way though intermediate and its confusing how to use map effectively
Sridevi2014
@Sridevi2014
Jun 02 2017 03:57
myVar is not defined outside of myLocalScope
Moisés Man
@moigithub
Jun 02 2017 03:58
@Netrunner21 map iterate the array
execute the function provided with each element
and return a new array result with same length
function add2(num){return num+2 }
[1,2,3].map( add2 )  // result [3,4,5]
Netrunner21
@Netrunner21
Jun 02 2017 03:59
So it's basically a for loop with a function inside?
Moisés Man
@moigithub
Jun 02 2017 04:00
yep. it internally have a loop
Netrunner21
@Netrunner21
Jun 02 2017 04:00
I saw someone solve title case a sentence using map and was curious how they did it. I may give that a whirl
Michael John Walsh
@michaelwalsh85
Jun 02 2017 04:00
Can anyone help with the escape sequences in strings Javascript exercise?
my code is
var myStr = "FristLine\n\SecondLine\\rThirdLine"; // Change this line
but for some reason it's not working. I'm paying attention to spacing and capitalisation.
Netrunner21
@Netrunner21
Jun 02 2017 04:00
Thanks @moigithub
CamperBot
@camperbot
Jun 02 2017 04:00
netrunner21 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3303 | @moigithub |http://www.freecodecamp.com/moigithub
Moisés Man
@moigithub
Jun 02 2017 04:01
function map(arr, func){
  var result=[];
  for(var i=0; i<arr.length; i++){
          result.push( func(arr[i] ) )
   }
  return result;
}
Netrunner21
@Netrunner21
Jun 02 2017 04:03
@moigithub what is func(arr[i] in that example. What does it do.
Moisés Man
@moigithub
Jun 02 2017 04:03
functions on javascript accept ANY kind of parameters
string numbers even functions
Netrunner21
@Netrunner21
Jun 02 2017 04:03
Wouldn't this just map the original array to result? Where arr == result?
Moisés Man
@moigithub
Jun 02 2017 04:04
arr == modified arr
Netrunner21
@Netrunner21
Jun 02 2017 04:04
Unless of course you made the function do something, is that what you are saying
the func inside the push
Moisés Man
@moigithub
Jun 02 2017 04:05
check the first code...
function add2(num){return num+2 }
[1,2,3].map( add2 )  // result [3,4,5]
Netrunner21
@Netrunner21
Jun 02 2017 04:05
I get what that does
Moisés Man
@moigithub
Jun 02 2017 04:05
to map.. u pass a function .. add2 on this example
Adam Faraj
@adamfaraj
Jun 02 2017 04:29
how do multiply a string by a number?
//jshint esversion: 6

function repeatStringNumTimes(str, num) {
  let strNum = str.split();
  return strNum;
}

repeatStringNumTimes("abc", 3);
//jshint esversion: 6

function repeatStringNumTimes(str, num) {
  let strNum = str.split();
  return strNum * num;
}

repeatStringNumTimes("abc", 3);
130mk
@130mk
Jun 02 2017 04:31
could anyone help me solve the stand in line? taking the first array off was done but adding the item to the last arrray is hard. dont i need to use .push?
Adam Faraj
@adamfaraj
Jun 02 2017 04:32
what does your code look like @130mk
130mk
@130mk
Jun 02 2017 04:33

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

Adam Faraj
@adamfaraj
Jun 02 2017 04:33
//jshint esversion: 6

function repeatStringNumTimes(str, num) {
  return str.repeat(num);
}

repeatStringNumTimes("abc", 3);
that worked btw guys.

function nextInLine(arr, item) {
  // Your code here
  arr.shift();
  item.push(arr);// 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));
i don't see a return statement anywhere?
link me the challenge

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

}

Joseph
@revisualize
Jun 02 2017 04:37
@130mk Out of order.
Bryan Reese
@breese8009
Jun 02 2017 04:37
return str.reapeat(num) only takes care of positive numbers
Adam Faraj
@adamfaraj
Jun 02 2017 04:38
yeah, i got it @breese8009 wrote an if else statement
Bryan Reese
@breese8009
Jun 02 2017 04:38
oh
sorry
shandanatowns
@shandanatowns
Jun 02 2017 04:40
Can someone help me with the convert celsius to farenheit challenge? I don't know JS and I've only learned add, subtract, and divide here in FCC. Now I'm confused as to how to complete this task with only these. Any nudge in the right direction would be greatly appreciated.
Adam Faraj
@adamfaraj
Jun 02 2017 04:42
@130mk

function nextInLine(arr, item) {
  // Your code here
  testArr.push(item);
  var firstItem = testArr.shift();
  return firstItem;
}

// 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));
i'm getting all of them except the 3rd one
lol

function nextInLine(arr, item) {
  // Your code here
  testArr.push(item);
  return testArr.shift();
}

// 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));
don't need that var firstItem
Mithun reddy
@mithunreddyt
Jun 02 2017 04:44
Don't need to bar that first item
Var*
It's just item
Adam Faraj
@adamfaraj
Jun 02 2017 04:45
yeah, i fixed it in the second block. i like variables. haha

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

// Test Setup
var testArr = [1,2,3,4,5];
// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
that worked
i kept using testArr instead of arr
@130mk
Mukul Agrawal
@mukul09
Jun 02 2017 04:47
@shandanatowns use this formula to change celsius to fahrenheit
fahrenheit=celsius*(9/5)+32;
Joseph
@revisualize
Jun 02 2017 04:48
@shandanatowns Seeing as someone just gave you the answer without really explaining why it is the answer.

@shandanatowns Here is why the answer is the answer:
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.

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

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

130mk
@130mk
Jun 02 2017 04:50
@adamfaraj ty
CamperBot
@camperbot
Jun 02 2017 04:50
130mk sends brownie points to @adamfaraj :sparkles: :thumbsup: :sparkles:
:cookie: 253 | @adamfaraj |http://www.freecodecamp.com/adamfaraj
Henry
@GitHub-Henry
Jun 02 2017 04:54
anyone here able and willing to simply explain CORS? would appreciate it.
just not getting why some times i get a cors error and other times i don't
have 2 https calls 1 gets cors error the other doesn't
https://codepen.io/fccHenry/pen/rwBOgp?editors=0011
shandanatowns
@shandanatowns
Jun 02 2017 04:55
@mukul09 and @revisualize thanks. I wasn't looking for the exact answer but I do appreciate it and the explination really helped better understand what I was supposed to be doing and why.
CamperBot
@camperbot
Jun 02 2017 04:55
shandanatowns sends brownie points to @mukul09 and @revisualize :sparkles: :thumbsup: :sparkles:
:cookie: 335 | @mukul09 |http://www.freecodecamp.com/mukul09
:star2: 4083 | @revisualize |http://www.freecodecamp.com/revisualize
Adam Faraj
@adamfaraj
Jun 02 2017 04:56
@GitHub-Henry above my skill level
Henry
@GitHub-Henry
Jun 02 2017 04:56
code works with cors work around, just trying to understand the error, and why I need the work around for 1 call and not for the other
@adamfaraj above mine also
anhlequoc @anhlequoc
Jeremy
@JeremyAntonoff
Jun 02 2017 04:59
can anyone help
Augusto
@hackedWifi
Jun 02 2017 05:08
can anyone tell me why this code does not work in the drop it challenge

`function dropElements(arr, func) {
// Drop them elements.

for(var i = 0; i<= arr.length ; i++){
if(func(arr[0])){
break;
}
else {
arr.shift();
}
}

return arr;

}`

john g
@jgwould
Jun 02 2017 05:16
Help with the following:

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

function checkObj(checkProp) {
  // Your Code Here
  if (myObj.hasOwnProperty(checkProp){
    return checkProp;
  }
    return "Not Found";
}
// Test your code by modifying these values
checkObj("gift");
On "Testing Objects for properties"
Don't see why this doesn't work
Augusto
@hackedWifi
Jun 02 2017 05:21
@jgwould are you not getttin the return 'Not Found"? statement
Markus Kiili
@Masd925
Jun 02 2017 05:21
@hackedWifi You mutate the array you iterate over with for. i increases and arr.length gets smaller. The last elements don't always get checked.
@hackedWifi Better would be a while loop that targets the first element.
Augusto
@hackedWifi
Jun 02 2017 05:23
Thanks @Masd925
CamperBot
@camperbot
Jun 02 2017 05:23
hackedwifi sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4182 | @masd925 |http://www.freecodecamp.com/masd925
Peter Kay
@deuscode
Jun 02 2017 05:26
@jgwould you might want to close that parantheses
```
if (myObj.hasOwnProperty(checkProp)) {
    return checkProp;
john g
@jgwould
Jun 02 2017 05:27
@hackedWifi yes
figured it out
Ratnesh Malviya
@ratneshmalviya123
Jun 02 2017 05:27
hey guys
Augusto
@hackedWifi
Jun 02 2017 05:27
@jgwould you were using () instead of []
john g
@jgwould
Jun 02 2017 05:27
shoud be return myObj[checkProp];
Augusto
@hackedWifi
Jun 02 2017 05:28
That is what i mean lol
john g
@jgwould
Jun 02 2017 05:28
silly code
Augusto
@hackedWifi
Jun 02 2017 05:28
silly YOU :)
Ratnesh Malviya
@ratneshmalviya123
Jun 02 2017 05:29
I want to remove all non-alphanumeric characters in a string, I'm using str.replace(/\W*/,""); but it does not work
not sure what I'm missing
Markus Kiili
@Masd925
Jun 02 2017 05:32
@ratneshmalviya123 The underscore _
Jeremy
@JeremyAntonoff
Jun 02 2017 05:32
function select(arr, obj) {
  // your code here
  var newObject = {};
  for (var i = 0; i <arr.length; i++) {
    if (obj.hasOwnProperty(arr[i])){
      newObject[arr[i]] == obj[arr[i]];

    }
    return newObject;
  }
}
select(['a', 'c', 'e'], {
  a: 1,
  b: 2,
  c: 3,
  d: 4
});
can someone tell me why this wont work. trying to only return the values that are in the array
so {a:1, c:3}
Adam Faraj
@adamfaraj
Jun 02 2017 05:33
guys im' having a brain fart
function truncateString(str, num) {
  let strLength = str.slice(0, num);
  let splitted = strLength.split("");
  return splitted.splice(-3);

}
Ratnesh Malviya
@ratneshmalviya123
Jun 02 2017 05:33
@Masd925 where should I use '_'
Markus Kiili
@Masd925
Jun 02 2017 05:33
@JToddFL Return after the loop block.
Adam Faraj
@adamfaraj
Jun 02 2017 05:33
returns the last 3 of the element
i want the opposite.
Markus Kiili
@Masd925
Jun 02 2017 05:34
@ratneshmalviya123 You can use [ ], \W, and _
Adam Faraj
@adamfaraj
Jun 02 2017 05:34
i want to return the array with the last 3 spliced out
Jeremy
@JeremyAntonoff
Jun 02 2017 05:34
@Masd925 I did. just a typo still returning a blank {}
Adam Faraj
@adamfaraj
Jun 02 2017 05:34
not the spliced out 3 arrays
Markus Kiili
@Masd925
Jun 02 2017 05:35
@JToddFL The brackets on the property generation line are not right. newObject[arr[i]] == obj[arr[i]]
Jeremy
@JeremyAntonoff
Jun 02 2017 05:36
@Masd925 they were just had a comparison operator instead of =
@Masd925 thanks though man
CamperBot
@camperbot
Jun 02 2017 05:36
jtoddfl sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4183 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Jun 02 2017 05:36
@JToddFL :+1:
Adam Faraj
@adamfaraj
Jun 02 2017 05:36
so how do i return the array with the last 3 items spliced out
[1,2,3,4,5,6] => [1,2,3]
130mk
@130mk
Jun 02 2017 05:38
could anyone help me the if loop for golf?
Adam Faraj
@adamfaraj
Jun 02 2017 05:38
lol, i got it
function truncateString(str, num) {
  let strLength = str.slice(0, num);
  let splitted = strLength.split("");
  splitted.splice(-3);
  return splitted;

}
in case anyone else was wondering
go ahead @130mk
Markus Kiili
@Masd925
Jun 02 2017 05:39
@adamfaraj You don't need arrays there. Better to use string operations.
130mk
@130mk
Jun 02 2017 05:39

@adamfaraj
function golfScore(par, strokes) {
// Only change code below this line

var a;
if (a,1) {
return "Hole-in-one!";
}
else if (par, par - 2) {
return "Eagle";
}
else if (par, par - 1) {
return "Birdie";
}
else if (par, par) {
return "Par";
}
else if (par, par + 1) {
return "Bogey";
}
else if (par, +2) {
return "Double Bogey";
}
else {
return "Go Home!";
} // Only change code above this line
}

// Change these values to test
golfScore(4, 2);

Adam Faraj
@adamfaraj
Jun 02 2017 05:41
you don't have any operands @130mk
130mk
@130mk
Jun 02 2017 05:41
got it, using operands here
Adam Faraj
@adamfaraj
Jun 02 2017 05:42
@130mk like this
if (strokes == 1) {
return "Hole-in-one!";
}
etc etc
@Masd925 what do you suggest
Markus Kiili
@Masd925
Jun 02 2017 05:43
@adamfaraj You can use string methods like slice/substr/substring for making a substring.
Adam Faraj
@adamfaraj
Jun 02 2017 05:44
true
but i'm knee deep into what i have. haha
will try to make it work
Tomas Lastrilla
@Tomas1337
Jun 02 2017 05:45

Hi, guys. My variable is returning null. Can you tell me why?
var factorIzed;
function factorialize(num) {

while (num>1){
factorIzed = factorIzed * num;
num--;

}

return factorIzed;

}

factorialize(5);

Markus Kiili
@Masd925
Jun 02 2017 05:45
@adamfaraj Doing arr.splice(3); would remove the elements from index 3->.
@Tomas1337 Initialize the variable inside the function.
Adam Faraj
@adamfaraj
Jun 02 2017 05:47
@Masd925 i'm doing this challenge "Truncate a string"
Tomas Lastrilla
@Tomas1337
Jun 02 2017 05:47
@Masd925 , still the same ...
Adam Faraj
@adamfaraj
Jun 02 2017 05:47
var factorIzed;
function factorialize(num) {
while (num>1){
factorIzed = factorIzed * num;
num--;
}
return factorIzed;
}
factorialize(5);
Markus Kiili
@Masd925
Jun 02 2017 05:48
@Tomas1337 You need to do var factorIzed = 1; inside the function.
Adam Faraj
@adamfaraj
Jun 02 2017 05:48
factorIzed is a global variable
and you haven't assigned it anything
variables declared within a function have local scope
what @Masd925 said
Tomas Lastrilla
@Tomas1337
Jun 02 2017 05:50
@Masd925 @adamfaraj ACK. also tried declaring it inside the function. What made it work was to initialize it with a value! SIMPLE mistake. Thanks guys! Can you tell me why that is though? I wouldve thought that factorIzed= factorIzed *num would make the program understand that its a integer already. Is that not the case?
CamperBot
@camperbot
Jun 02 2017 05:50
tomas1337 sends brownie points to @masd925 and @adamfaraj :sparkles: :thumbsup: :sparkles:
:cookie: 254 | @adamfaraj |http://www.freecodecamp.com/adamfaraj
:star2: 4184 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Jun 02 2017 05:51
@Tomas1337 An uninitialized variable has value undefined and when you multiply it with a number there it becomes NaN and then again NaN etc.
Tomas Lastrilla
@Tomas1337
Jun 02 2017 05:52
I see! Very useful info. Thanks @Masd925
CamperBot
@camperbot
Jun 02 2017 05:52
tomas1337 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: tomas1337 already gave masd925 points
Kris Baillargeon
@krisb1220
Jun 02 2017 05:52

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

        return contacts[x].firstName + "," + contacts[x][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");
quick formatting question... how would I format that snippet to output "Akira", "//Akiras Likes" and etc
Markus Kiili
@Masd925
Jun 02 2017 05:53
@krisb1220 Just return contacts[x][prop];
@krisb1220 The logic for the last return is wrong. Return when you have checked all the contacts.
Kris Baillargeon
@krisb1220
Jun 02 2017 05:54
So make that the very last thing the function does? and contacts[x][prop]; doesn't pass the challenge either but it's outputting in that format.. let me try a couple things :P thanks @Masd925
CamperBot
@camperbot
Jun 02 2017 05:54
krisb1220 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4185 | @masd925 |http://www.freecodecamp.com/masd925
Kris Baillargeon
@krisb1220
Jun 02 2017 05:55
If firstName does not correspond to any contacts then return "No such contact"

If prop does not correspond to any valid properties then return "No such property"
are you sure I don't have to individually check them?
Markus Kiili
@Masd925
Jun 02 2017 05:56
@krisb1220 Just move the last return to correct spot and it works.
Kris Baillargeon
@krisb1220
Jun 02 2017 05:56
lemme try
Markus Kiili
@Masd925
Jun 02 2017 05:56
@krisb1220 The logic is to return inside the loop if you find the correct contact and after the loop if you don't.
Use var x=0
Adam Faraj
@adamfaraj
Jun 02 2017 06:01
@Masd925
i have spaghetti code
Farmerwan
@muntanui
Jun 02 2017 06:07
Am I missing something here?:
// 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");
Kris Baillargeon
@krisb1220
Jun 02 2017 06:07
@Masd925 sorry I was off trying to figure it out, but NOW i think I fully see what you're saying :P I'll try that and will do with the var
Nathan
@clarken1996
Jun 02 2017 06:10
sorry what am I missing? myArray.unshift("Paul", 35);
sorry what am I missing here?- myArray.unshift("Paul", 35);
Rid Amsal
@RidAmsal
Jun 02 2017 06:13
guys, im suck in 122, Understanding Uninitialized Variables. help needed pls
Joseph
@revisualize
Jun 02 2017 06:14
@muntanui You're not modifying result
@muntanui You created the object. Great.
Nathan
@clarken1996
Jun 02 2017 06:14
@RidAmsal what you need help with?
Joseph
@revisualize
Jun 02 2017 06:14
@muntanui But, you need to have another line item that modifies the value of the result variable and assign the object property value
Rid Amsal
@RidAmsal
Jun 02 2017 06:15
@clarken1996 i dont know how to solve this one,
Kris Baillargeon
@krisb1220
Jun 02 2017 06:15
function lookUpProfile(firstName, prop){
// Only change code below this line
  for(var x=0;x < contacts.length;x++) { 
    if(firstName === contacts[x].firstName) {
      if(contacts[x].hasOwnProperty(prop)) {

        return contacts[x][prop];
      } 
    }
  }

  for(var y=0;y < contacts.length;y++) { 
    if(contacts[y].firstName != firstName) { 
      return "No such contact";
    }
  return "No such property"
  } 
}

// Only change code above this line

// Change these values to test your function
lookUpProfile("Akira", "likes");
Well I've found this less-than-elegant solution.. Anybody know any ways to optimize it with less loops?
Joseph
@revisualize
Jun 02 2017 06:16
@krisb1220 Yes.
@krisb1220 You only need 1 for loop.
Vedant Kashyap
@vedant15188
Jun 02 2017 06:17
How do I convert "thisIsSpinalTap" to "this-is-spinal-tap" in Spinal Tap Case Challenge?
https://www.freecodecamp.com/challenges/spinal-tap-case
How will regex check if there's a lowercase alphabet right before the capitalized alphabet?
Nathan
@clarken1996
Jun 02 2017 06:17
@RidAmsal // Initialize these three variables
var a =5;
var b =10;
var c = "I am a";
its just worded badly
Farmerwan
@muntanui
Jun 02 2017 06:18
@revisualize I tried using result = lookup(); but that didn't work
Kris Baillargeon
@krisb1220
Jun 02 2017 06:18
For some reason this challenge really made me scratch my head :P took me literally all day and like 5 separate tries
Joseph
@revisualize
Jun 02 2017 06:18
@muntanui Well, Lookup isn't a function. So that won't work.
@muntanui How do you access an object property?
@krisb1220 Let's break it down.
@krisb1220 So, you have an array. contacts
@krisb1220 Each array element is an object.
@krisb1220 Right?
Vedant Kashyap
@vedant15188
Jun 02 2017 06:21
@forwebtech I solved it... Thanks!
CamperBot
@camperbot
Jun 02 2017 06:21
vedant15188 sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
:cookie: 652 | @forwebtech |http://www.freecodecamp.com/forwebtech
Kris Baillargeon
@krisb1220
Jun 02 2017 06:22
Sorry sorry was trying to implement that one for loop
Correct, yes :P
Joseph
@revisualize
Jun 02 2017 06:22
@krisb1220 Okay. So.
Kris Baillargeon
@krisb1220
Jun 02 2017 06:23
we're bout to @revisualize
sorry i had to
Joseph
@revisualize
Jun 02 2017 06:23
@krisb1220 if firstName is an actual contact's firstName
@krisb1220 That's this line: if(firstName === contacts[x].firstName) {
@krisb1220 and the given property (prop) is a property of that contact.
Rid Amsal
@RidAmsal
Jun 02 2017 06:23
Dear @clarken1996 , thanks alot. how do you come up with that thought ? its hard for me to see that, but after you saw it, then its there
CamperBot
@camperbot
Jun 02 2017 06:24
ridamsal sends brownie points to @clarken1996 :sparkles: :thumbsup: :sparkles:
:cookie: 168 | @clarken1996 |http://www.freecodecamp.com/clarken1996
Kris Baillargeon
@krisb1220
Jun 02 2017 06:24
Yes correct
Joseph
@revisualize
Jun 02 2017 06:24
@krisb1220 That's this line: if(contacts[x].hasOwnProperty(prop)) {
@krisb1220 If both are true, then return the "value" of that property.
@krisb1220 That's this line return contacts[x][prop];
@krisb1220 Now... If prop does not correspond to any valid properties then return "No such property"
Kris Baillargeon
@krisb1220
Jun 02 2017 06:25
Initially I was thinking that it wanted me to return both the name and the property :P boy was I mad LOL
I tried adding nested else statements and that doesn't output the property but outputs the correct string when it's not in the array :P
Joseph
@revisualize
Jun 02 2017 06:25
@krisb1220 So, if(contacts[x].hasOwnProperty(prop)) { ... Is NOT true .... You need to return "No such property"
Markus Kiili
@Masd925
Jun 02 2017 06:26
@krisb1220 I told you to just move that last return. Not to explode it to a mess ;)
Kris Baillargeon
@krisb1220
Jun 02 2017 06:26
No I did it
It worked
Thank you
I'm trying to optimize it
Joseph
@revisualize
Jun 02 2017 06:26
@krisb1220 Are you reading what I'm writing?
Kris Baillargeon
@krisb1220
Jun 02 2017 06:26
No I am, sorry I was responding to @Masd925
Olivier
@Bluearrowww2
Jun 02 2017 06:27

Hi every one.
I stuck witk:
Finding a Remainder in JavaScript.

Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator.

Joseph
@revisualize
Jun 02 2017 06:27
@krisb1220 Okay. So how would you correct your if statement about the properties?
@Bluearrowww2 Remainder:
http://images.tutorvista.com/cms/images/38/remainder1.PNG
13 % 2 is 1 ... 26 % 5 is 1 ... 24 % 6 is 0
24 % 5 is 4 ... 219 % 20 is 19
Just like in my examples above you use the % operator just like any other math operator (+, -, *, /)
Kris Baillargeon
@krisb1220
Jun 02 2017 06:28
errr....
gimme a sec LOL
Vedant Kashyap
@vedant15188
Jun 02 2017 06:28
How do I convert "thisIsSpinalTap" to "this-is-spinal-tap" in Spinal Tap Case Challenge?
https://www.freecodecamp.com/challenges/spinal-tap-case
How will regex check if there's a lowercase alphabet right before the capitalized alphabet?
Markus Kiili
@Masd925
Jun 02 2017 06:29
@krisb1220 The simplest way is a for loop and two nested if's and the returns. You cannot optimize it any more.
Kris Baillargeon
@krisb1220
Jun 02 2017 06:29
I am honestly at a loss here :P maybe it's just too late
Joseph
@revisualize
Jun 02 2017 06:29
@krisb1220 How do you return one thing if something is true. And return something else if it isn't?
Kris Baillargeon
@krisb1220
Jun 02 2017 06:29
!= ?
Joseph
@revisualize
Jun 02 2017 06:30
@krisb1220 Ignore the challenge. Just give me something BASIC
@krisb1220 No.
@krisb1220 if something is true return "one" otherwise return "none"
Kris Baillargeon
@krisb1220
Jun 02 2017 06:30
I'm sorry it's 2:30 AM LOL I'm not in my prime rn
Joseph
@revisualize
Jun 02 2017 06:30
@krisb1220 Good.
Kris Baillargeon
@krisb1220
Jun 02 2017 06:30
ohhhhhh
wait so
like what @Masd925 said
Olivier
@Bluearrowww2
Jun 02 2017 06:31
@krisb1220 I understand but how to correctly write it? That's my point.
ur0sh
@ur0sh
Jun 02 2017 06:31
function destroyer(arr) {
  // Remove all the values
  return arr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Why is it, when you run the function, the last 2 arguments are not returned. So it returns only the numbers inside the square brackets?
Joseph
@revisualize
Jun 02 2017 06:31
@Masd925 I don't care what @Masd925 said. He's smarter than me and it upsets me sometimes.
Markus Kiili
@Masd925
Jun 02 2017 06:31
@ur0sh One parameter only catches the first passed argument.
Joseph
@revisualize
Jun 02 2017 06:31
:trollface:
:P
:heart:
Markus Ivancsics
@ivancsicsmarkus
Jun 02 2017 06:32
@ur0sh Because arr is the first argument, which is the array you pass in.
Kris Baillargeon
@krisb1220
Jun 02 2017 06:32
return it but because it returns it'll exit the function - else it returns no such property
....
Joseph
@revisualize
Jun 02 2017 06:32
@krisb1220 Write that for me.
Markus Ivancsics
@ivancsicsmarkus
Jun 02 2017 06:32
@ur0sh You can return the whole input with return arguments;
Kris Baillargeon
@krisb1220
Jun 02 2017 06:32
Let me try some stuff out uno momento
Vedant Kashyap
@vedant15188
Jun 02 2017 06:32
@ur0sh its because arr is an argument object... so you will have to make an array containing the elements in that argument
Joseph
@revisualize
Jun 02 2017 06:33
@krisb1220 Don't "try" some stuff out. You're just making an if / else statement.
Kris Baillargeon
@krisb1220
Jun 02 2017 06:33
If I get it right the first time I'll only have to try that out I just don't want you to think I'm ignoring you if I'm gone for an extended amount of time, I am trying to do this :P
ur0sh
@ur0sh
Jun 02 2017 06:33
so in this case if I, theoreticaly wnated to run all thre, there would have to be 3 parameters inside the function right?
Joseph
@revisualize
Jun 02 2017 06:33
@krisb1220 It's 1133pm here. I need my if / else statement.
Kris Baillargeon
@krisb1220
Jun 02 2017 06:34
<3
ur0sh
@ur0sh
Jun 02 2017 06:34
three
Kris Baillargeon
@krisb1220
Jun 02 2017 06:34
It's 2:30 AM here, like I said not in my prime :P
Joseph
@revisualize
Jun 02 2017 06:34
@krisb1220 GOOD!
@krisb1220 Fuck your comfort zone.
@krisb1220 Be amazing.
Olivier
@Bluearrowww2
Jun 02 2017 06:35
@revisualize Ok i get it. But how to write it? That's my point.
ur0sh
@ur0sh
Jun 02 2017 06:35
thank you guys
Markus Kiili
@Masd925
Jun 02 2017 06:35
@revisualize It is time to talk again about why Object.length is 1 :trollface:
Joseph
@revisualize
Jun 02 2017 06:36

@Bluearrowww2 If I have this object:

var myFriend = {
        "firstName": "Happy",
        "lastName": "Feet",
        "number": "-i",
        "likes": ["rhythm", "dancing", "soul"]
    }

And I have a variable: value = "number";
How do I use my object to access myFriend 's favorite number (using the variable)?

Markus Ivancsics
@ivancsicsmarkus
Jun 02 2017 06:37
@revisualize myFriend[value]
Olivier
@Bluearrowww2
Jun 02 2017 06:37
Thank you my friend. I succeed! @revisualize
CamperBot
@camperbot
Jun 02 2017 06:37
bluearrowww2 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4084 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Jun 02 2017 06:37

@Bluearrowww2 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.

@krisb1220 Did you break your code?
Kris Baillargeon
@krisb1220
Jun 02 2017 06:39
Uh
Kinda
It's working a little
Joseph
@revisualize
Jun 02 2017 06:39
@krisb1220 Show me.
Kris Baillargeon
@krisb1220
Jun 02 2017 06:39
too well
function lookUpProfile(firstName, prop){
// Only change code below this line
  for(var x=0;x < contacts.length;x++) { 
    if(firstName === contacts[x].firstName) {
      if(contacts[x].hasOwnProperty(prop)) {

        return contacts[x][prop];
      } 
    } else if(contacts[x].firstName != firstName) { 
      return "No such contact";
    }
    return "No such property";
}
}
I realize that you did tell me not to use !=, but I'm trying
.. :P
Joseph
@revisualize
Jun 02 2017 06:40
@krisb1220
@krisb1220 Come on.
Kris Baillargeon
@krisb1220
Jun 02 2017 06:41
its late
Joseph
@revisualize
Jun 02 2017 06:41
@krisb1220 You just needed an ELSE
Not an else if.
@krisb1220 If
if(contacts[x].hasOwnProperty(prop))
is not true. You're supposed to
return "No such property";
Markus Kiili
@Masd925
Jun 02 2017 06:42
@krisb1220 I said an hour ago The logic is to return inside the loop if you find the correct contact and after the loop if you don't.
Joseph
@revisualize
Jun 02 2017 06:42

@krisb1220

else if(contacts[x].firstName != firstName) { 
      return "No such contact";
    }

I never said to put any of this in your for loop.

@krisb1220 We were not even talking about No such contact.
Kris Baillargeon
@krisb1220
Jun 02 2017 06:43
wait
but
thats what I was talking about originally...
its late
Joseph
@revisualize
Jun 02 2017 06:43
@krisb1220 I wasn't.
Kris Baillargeon
@krisb1220
Jun 02 2017 06:43
I see...
Oops
Well
I made enough of an idiot out of myself for one day
Joseph
@revisualize
Jun 02 2017 06:44
:|
Kris Baillargeon
@krisb1220
Jun 02 2017 06:44
thanks @revisualize LOL
CamperBot
@camperbot
Jun 02 2017 06:44
krisb1220 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4085 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Jun 02 2017 06:45
@krisb1220
// A lookUpProfile function that takes firstName 
// and a property (prop) as arguments has been pre-written for you.
function lookUpProfile(firstName, prop){
   for (var i=0; i < contacts.length; i++){
      // The function should check if firstName 
      // is an actual contact's firstName 
      if (contacts[i]["firstName"] == firstName) {
         // and the given property (prop) is a property of that contact.
         if(contacts[i].hasOwnProperty(prop)) {
             // If both are true, 
             // then return the "value" of that property.
             return contacts[i][prop]; 
          } else {
             // If prop does not correspond to any valid properties
             // then return "No such property".
             return "No such property";
          }
       }
   }
   // If firstName does not correspond to "any" contacts (key word is any)
   // then return "No such contact"
   return "No such contact";
}
Kris Baillargeon
@krisb1220
Jun 02 2017 06:46
Yeah
I should proooobably go back a little ways
Pulling red eyes won't do me any good LOL
Thanks so much for all your help man
Proconsul
@proconsu1
Jun 02 2017 06:48
howdy ho. just finished this challenge, but now i'm trying to figure out a better way to automate that doesn't rely on a while loop. problem is i cant seem to figure a way to make any array methods i can find do quite what's needful. .map seems not to be suited to it, but i feel like i'm not seeing some obvious possibility. any ideas?

function chunkArrayInGroups(arr, size) {
  var arr2 = [];
  var i = 0;
  while ( i < arr.length){
    arr2.push(arr.slice(i,i+size));
    i += size;
  }

  return arr2;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
Kris Baillargeon
@krisb1220
Jun 02 2017 06:48
oh no
@revisualize you wanna answer his question ? LOL
<3
nighty night
Markus Ivancsics
@ivancsicsmarkus
Jun 02 2017 06:49
@proconsu1 I think this is a good solution.
Joseph
@revisualize
Jun 02 2017 06:49
@proconsu1 That's actually a good solution.
Markus Ivancsics
@ivancsicsmarkus
Jun 02 2017 06:49
@proconsu1 There is no problem with this.
Joseph
@revisualize
Jun 02 2017 06:50
@proconsu1 You could use a for loop if you wanted.
@proconsu1 But, you'd be doing all the same things.
Proconsul
@proconsu1
Jun 02 2017 06:50
gah. went to a while cuz i felt like i was getting in a rut turning to for loops for every challenge ;-)
Joseph
@revisualize
Jun 02 2017 06:51
@proconsu1 So, there's a bit of an unspoken-ish rule about loops.
Proconsul
@proconsu1
Jun 02 2017 06:51
@revisualize lay it on me
Joseph
@revisualize
Jun 02 2017 06:51
@proconsu1 If you can figure out how many times something is going to loop before you run the loop. ... Use a for loop.
@proconsu1 If you can't really figure out how many times something is going to run before you start the loop. ... use a while loop
@proconsu1 If you need something to run at least once and you don't know how many times it is going to run afterwards... use a do while loop
@proconsu1 Wit this challenge.. You can figure out how many times something is going to loop before you run it.
@proconsu1 i < arr.length
130mk
@130mk
Jun 02 2017 06:53

anyone can help how to solve the blackjack counting cards coding?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 'Q':
case 'K':
case 'A':
count -= 1;

}
if (count > 0) {
count += " BET";
} else {
count += " Hold";
}

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

// Add/remove calls to test your function.
// Note: Only the last will display
cc(10); cc('J'); cc('Q'); cc('K'); cc('A');

Joseph
@revisualize
Jun 02 2017 06:53
@proconsu1 Note: This "unspoken-ish" rule ... isn't a rule at all.
@130mk Lowercase the et in Bet
130mk
@130mk
Jun 02 2017 06:54
ty, still wrong
Joseph
@revisualize
Jun 02 2017 06:54
@130mk Also, you shouldn't be adding a string to count.
130mk
@130mk
Jun 02 2017 06:54
gives me NaN Hold
Joseph
@revisualize
Jun 02 2017 06:54
@130mk Global variables do not reset when a function is ran.
@130mk You should turn your if statements into return's
@130mk You're getting NaN when you try to do count -= 1; because you're turning count into a string.
@130mk Don't turn the global variable count into a string.
130mk
@130mk
Jun 02 2017 06:56
i get the problems but the solutions are still mystery
Joseph
@revisualize
Jun 02 2017 06:57

@130mk

if (count > 0) {
count += " BET";
} else {
count += " Hold";
}

Don't do +=

Jeremy
@JeremyAntonoff
Jun 02 2017 06:57
can someone help
Proconsul
@proconsu1
Jun 02 2017 06:57
@JToddFL whatcha got?
Joseph
@revisualize
Jun 02 2017 06:58
@130mk Counting Cards is a challenge where your function will receive a card parameter. You're supposed to increment or decrement the global count variable according to the card's value
If the value of the card parameter is 2, 3, 4, 5 or 6 you need to increment the global variable count.
If the value of the card parameter is 10, 'J', 'Q', 'K' or 'A' you need to decrement the global variable count.
...
Then the function will return a string with the current count and the string "Bet" if the count is positive, or "Hold" if the count is zero or negative.
The current count and the player's decision ("Bet" or "Hold") should be separated by a single space.
...
...
Things to note: You should NOT be returning based on the value of the card. The value of card should only be adding or subtracting 1 from the global variable count.
The value of the global variable count is used to determine the return statement.
Proconsul
@proconsu1
Jun 02 2017 06:58
oh, and thanks @revisualize :-)
CamperBot
@camperbot
Jun 02 2017 06:58
proconsu1 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4086 | @revisualize |http://www.freecodecamp.com/revisualize
Jeremy
@JeremyAntonoff
Jun 02 2017 06:58
ok I'm trying to transform these two arrays into objects @proconsu1
function transformEmployeeData(array) {
  // your code here
  var output = {};
  var arrOutput = [];

  for (var i =0; i < array.length; i++) {
    for (var j =0; j < array[i].length; j++) {
       output[array[i][j][0]] = array[i][j][1]


    }
   arrOutput.push(output);
}
return arrOutput;
}
transformEmployeeData([
    [
        ['firstName', 'Joe'], ['lastName', 'Blow'], ['age', 42], ['role', 'clerk']
    ],
    [
        ['firstName', 'Mary'], ['lastName', 'Jenkins'], ['age', 36], ['role', 'manager']
    ]
])
im getting this as output
=> [ { firstName: 'Mary',
    lastName: 'Jenkins',
    age: 36,
    role: 'manager' },
  { firstName: 'Mary',
    lastName: 'Jenkins',
    age: 36,
    role: 'manager' } ]
Proconsul
@proconsu1
Jun 02 2017 06:58
@ivancsicsmarkus and thanks to you, too! almost forgot ya
CamperBot
@camperbot
Jun 02 2017 06:58
proconsu1 sends brownie points to @ivancsicsmarkus :sparkles: :thumbsup: :sparkles:
:cookie: 563 | @ivancsicsmarkus |http://www.freecodecamp.com/ivancsicsmarkus
Joseph
@revisualize
Jun 02 2017 06:59
@JToddFL Hack Reactor Prep?
Jeremy
@JeremyAntonoff
Jun 02 2017 06:59
yes
Proconsul
@proconsu1
Jun 02 2017 07:00
@JToddFL when you defined the var output you made it an object with {} instead of an array with [] - was that intentional? (i dont the instructions you are trying to follow there)
130mk
@130mk
Jun 02 2017 07:00
@revisualize getting closer to finishing but still not done.
it's quite hard
Joseph
@revisualize
Jun 02 2017 07:01
@130mk Show me your if
Jeremy
@JeremyAntonoff
Jun 02 2017 07:01
@proconsu1 yes i want it to output as two objects within an array
130mk
@130mk
Jun 02 2017 07:01
@revisualize if (count > 0) {
count = " Bet";
} else {
count = " Hold";
}
Joseph
@revisualize
Jun 02 2017 07:01
@130mk Those should be RETURN statements.
Your return should be based on the value of count.
@130mk count should ALWAYS stay a number.
130mk
@130mk
Jun 02 2017 07:02
if (count > 0) {
return count +" Bet";
} else {
return count +" Hold";
}?
like this?
Joseph
@revisualize
Jun 02 2017 07:02
@130mk Try it.
Jeremy
@JeremyAntonoff
Jun 02 2017 07:02
@proconsu1 exactly the output I have now only the first object needs to match the first Array
130mk
@130mk
Jun 02 2017 07:02
@revisualize omg ty!
CamperBot
@camperbot
Jun 02 2017 07:02
130mk sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4087 | @revisualize |http://www.freecodecamp.com/revisualize
130mk
@130mk
Jun 02 2017 07:02
done
Proconsul
@proconsu1
Jun 02 2017 07:03
@JToddFL k. sec. looking at it again
Paurush
@Paurush0506
Jun 02 2017 07:03
what is concatenate
Jeremy
@JeremyAntonoff
Jun 02 2017 07:03
puts two arrays together
Paurush
@Paurush0506
Jun 02 2017 07:04
thanks
Joseph
@revisualize
Jun 02 2017 07:04
@JToddFL I used .reduce()
Jeremy
@JeremyAntonoff
Jun 02 2017 07:05
for my problem?
I am so close to solving it lol. Had the output repeat twice though.
Karan
@karan171996
Jun 02 2017 07:07
function checkObj(checkProp) {

  if(myObj.hasOwnProperty("checkProp")){
   return myObj[checkProp];
  }
  else
  return "Not Found";
}
My Code Print "Not Found"
Joseph
@revisualize
Jun 02 2017 07:07
@killerkaran "checkProp" ... Should checkProp be a string?
irs1996
@irs1996
Jun 02 2017 07:08

guys need in help in where do I belong task
function getIndexToIns(arr, num) {
// Find my place in this sorted array.
arr.sort(function(a,b){
return a-b;
});
function test(val){
if(num>arr[arr.length-1]){
return arr[arr.length-1];
}
else if(val>=num){
return val;
}

}
var position= arr.findIndex(test);
return position;

}
getIndexToIns([2,5,10],15);
pls tell me what is the problem.

Markus Kiili
@Masd925
Jun 02 2017 07:08
@irs1996 It is much simpler if you first push num into arr and then sort.
Emmanuel Akodia
@akodiaemma
Jun 02 2017 07:08
CHECK OUT MY PAGE GUYS
Jeremy
@JeremyAntonoff
Jun 02 2017 07:08
@revisualize for my problem you used reduce?
Emmanuel Akodia
@akodiaemma
Jun 02 2017 07:08
I NEED HELP WITH FONTAWESOME.JS
Karan
@karan171996
Jun 02 2017 07:08
@revisualize thanks
CamperBot
@camperbot
Jun 02 2017 07:08
killerkaran sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4088 | @revisualize |http://www.freecodecamp.com/revisualize
heroiczero
@heroiczero
Jun 02 2017 07:09
@akodia488 :+1: Nice job like the particles
irs1996
@irs1996
Jun 02 2017 07:09
ok thankyou @Masd925
CamperBot
@camperbot
Jun 02 2017 07:09
irs1996 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4186 | @masd925 |http://www.freecodecamp.com/masd925
Joseph
@revisualize
Jun 02 2017 07:09
@JToddFL Yes.
Jeremy
@JeremyAntonoff
Jun 02 2017 07:10
@revisualize interesting. I don't have much experience with that. I'll look into it
Emmanuel Akodia
@akodiaemma
Jun 02 2017 07:11
@heroiczero how about the pirate picture, does it suit the sirtuation
Proconsul
@proconsu1
Jun 02 2017 07:12
@JToddFL sorry. hadda go afk and try to convince the dog he was in trouble
Jeremy
@JeremyAntonoff
Jun 02 2017 07:12
@proconsu1 no problem buddy
@revisualize I dont understand how the code is making a count for each word with the :
var names = ['Alice', 'Bob', 'Tiff', 'Bruce', 'Alice'];

var countedNames = names.reduce(function (allNames, name) { 
  if (name in allNames) {
    allNames[name]++;
  }
  else {
    allNames[name] = 1;
  }
  return allNames;
}, {});
Joel Korcsmaros
@lossness
Jun 02 2017 07:14
whats up everyone? Back in here with a question. in "Factorialize a number" is arithmetic operators the only reference I need?
Markus Kiili
@Masd925
Jun 02 2017 07:15
@lossness A loop of some kind is needed also.
Joel Korcsmaros
@lossness
Jun 02 2017 07:16
@Masd925 ok thanks for the hint ill get back at it
CamperBot
@camperbot
Jun 02 2017 07:16
lossness sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4187 | @masd925 |http://www.freecodecamp.com/masd925
Proconsul
@proconsu1
Jun 02 2017 07:16
@JToddFL you could try to more or less translate it into the newer approach, commenting out what you wrote and writing the new code below it
Jeremy
@JeremyAntonoff
Jun 02 2017 07:18
@proconsu1 I do. With my problem though should i just start over?
130mk
@130mk
Jun 02 2017 07:18
need help again
Accessing Objects Properties with Variables

// Setup
var testObj = {
12: "Namath",
16: "Montana",
19: "Unitas"
};

// Only change code below this line;

var playerNumber = testObj[player]; // Change this Line
var player = testObj; // Change this Line

Joseph
@revisualize
Jun 02 2017 07:19
@130mk Are you just doing Ask, Ask, Ask?
Read, Search, Ask
mitron6
@mitron6
Jun 02 2017 07:20
@130mk You are supposed to use a variable to lookup player 16. Where is your 16?
130mk
@130mk
Jun 02 2017 07:20
@revisualize I cleared 3 tasks after the counting card, thanks to you
CamperBot
@camperbot
Jun 02 2017 07:20
130mk sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: 130mk already gave revisualize points
Proconsul
@proconsu1
Jun 02 2017 07:21
@JToddFL gah dog again. guess he didnt believe me before. brb
mitron6
@mitron6
Jun 02 2017 07:21
@130mk var PlayerNumber = ??? What goes here?
heroiczero
@heroiczero
Jun 02 2017 07:22
@130mk its not a race just take it one step at a time. It is better to get in the habit of Read, Search and Ask.
Robert Arifin
@renkachan
Jun 02 2017 07:23
guys , i am still stuck at symmetric difference challenge, mind share a hint ? i stuck at checking if the array contain multiple same number
130mk
@130mk
Jun 02 2017 07:23
@mitron6 cleared!
@mitron6 ty
CamperBot
@camperbot
Jun 02 2017 07:23
130mk sends brownie points to @mitron6 :sparkles: :thumbsup: :sparkles:
:cookie: 706 | @mitron6 |http://www.freecodecamp.com/mitron6
arjav2002
@arjav2002
Jun 02 2017 07:26

`function checkCashRegister(price, cash, cid) {
var change, changeDue = cash - price, dollarsInDrawer = 0.0;
for(var i = 0; i < cid.length; i++)
dollarsInDrawer += cid[1][1];
// Here is your change, ma'am.
return dollarsInDrawer;
}

// Example cash-in-drawer array:
// [["PENNY", 1.01], // 1 c
// ["NICKEL", 2.05], // 5 c
// ["DIME", 3.10], // 10 c
// ["QUARTER", 4.25], // 25 c
// ["ONE", 90.00], // 1 $
// ["FIVE", 55.00], // 5 $
// ["TEN", 20.00], // 10 $
// ["TWENTY", 60.00], // 20 $
// ["ONE HUNDRED", 100.00]] // 100 $

checkCashRegister(19.50, 20.00, [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.10], ["QUARTER", 4.25], ["ONE", 90.00], ["FIVE", 55.00], ["TEN", 20.00], ["TWENTY", 60.00], ["ONE HUNDRED", 100.00]]);
` returns 18.450000000000003. Explain this s**t (referring to the meme)

``function checkCashRegister(price, cash, cid) {
var change, changeDue = cash - price, dollarsInDrawer = 0.0;
for(var i = 0; i < cid.length; i++)
dollarsInDrawer += cid[1][1];
// Here is your change, ma'am.
return dollarsInDrawer;
}

// Example cash-in-drawer array:
// [["PENNY", 1.01], // 1 c
// ["NICKEL", 2.05], // 5 c
// ["DIME", 3.10], // 10 c
// ["QUARTER", 4.25], // 25 c
// ["ONE", 90.00], // 1 $
// ["FIVE", 55.00], // 5 $
// ["TEN", 20.00], // 10 $
// ["TWENTY", 60.00], // 20 $
// ["ONE HUNDRED", 100.00]] // 100 $

checkCashRegister(19.50, 20.00, [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.10], ["QUARTER", 4.25], ["ONE", 90.00], ["FIVE", 55.00], ["TEN", 20.00], ["TWENTY", 60.00], ["ONE HUNDRED", 100.00]]);
``

Goddamit how am I supposed to format code??
var a = 5;

``function checkCashRegister(price, cash, cid) {
var change, changeDue = cash - price, dollarsInDrawer = 0.0;
for(var i = 0; i < cid.length; i++)
dollarsInDrawer += cid[1][1];
// Here is your change, ma'am.
return dollarsInDrawer;
}

// Example cash-in-drawer array:
// [["PENNY", 1.01], // 1 c
// ["NICKEL", 2.05], // 5 c
// ["DIME", 3.10], // 10 c
// ["QUARTER", 4.25], // 25 c
// ["ONE", 90.00], // 1 $
// ["FIVE", 55.00], // 5 $
// ["TEN", 20.00], // 10 $
// ["TWENTY", 60.00], // 20 $
// ["ONE HUNDRED", 100.00]] // 100 $

checkCashRegister(19.50, 20.00, [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.10], ["QUARTER", 4.25], ["ONE", 90.00], ["FIVE", 55.00], ["TEN", 20.00], ["TWENTY", 60.00], ["ONE HUNDRED", 100.00]]);``

Manish Giri
@Manish-Giri
Jun 02 2017 07:28
```
code
```
arjav2002
@arjav2002
Jun 02 2017 07:28

```function checkCashRegister(price, cash, cid) {
var change, changeDue = cash - price, dollarsInDrawer = 0.0;
for(var i = 0; i < cid.length; i++)
dollarsInDrawer += cid[1][1];
// Here is your change, ma'am.
return dollarsInDrawer;
}

// Example cash-in-drawer array:
// [["PENNY", 1.01], // 1 c
// ["NICKEL", 2.05], // 5 c
// ["DIME", 3.10], // 10 c
// ["QUARTER", 4.25], // 25 c
// ["ONE", 90.00], // 1 $
// ["FIVE", 55.00], // 5 $
// ["TEN", 20.00], // 10 $
// ["TWENTY", 60.00], // 20 $
// ["ONE HUNDRED", 100.00]] // 100 $

checkCashRegister(19.50, 20.00, [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.10], ["QUARTER", 4.25], ["ONE", 90.00], ["FIVE", 55.00], ["TEN", 20.00], ["TWENTY", 60.00], ["ONE HUNDRED", 100.00]]);```

See it doesn't work with multiple lines
function checkCashRegister(price, cash, cid) {
  var change, changeDue = cash - price, dollarsInDrawer = 0.0;
  for(var i = 0; i < cid.length; i++)
    dollarsInDrawer += cid[1][1];
  // Here is your change, ma'am.
  return dollarsInDrawer;
}

// Example cash-in-drawer array:
// [["PENNY", 1.01], // 1 c
// ["NICKEL", 2.05], // 5 c
// ["DIME", 3.10], // 10 c
// ["QUARTER", 4.25], // 25 c
// ["ONE", 90.00], // 1 $
// ["FIVE", 55.00], // 5 $ 
// ["TEN", 20.00], // 10 $
// ["TWENTY", 60.00], // 20 $
// ["ONE HUNDRED", 100.00]] // 100 $

checkCashRegister(19.50, 20.00, [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.10], ["QUARTER", 4.25], ["ONE", 90.00], ["FIVE", 55.00], ["TEN", 20.00], ["TWENTY", 60.00], ["ONE HUNDRED", 100.00]]);
Yes please explain why it returns 18.450000000000003
It is not even division!
it is a simple addition!
Markus Kiili
@Masd925
Jun 02 2017 07:30
@arjav2002 Only small enough integers are guaranteed to have an exact representation as floats (all JS numbers are 64bit floats).
arjav2002
@arjav2002
Jun 02 2017 07:30
@Masd925 Aren't these integers small?
I mean floats
Markus Kiili
@Masd925
Jun 02 2017 07:30
@arjav2002 18.45 is not an integer.
arjav2002
@arjav2002
Jun 02 2017 07:31
aren' they small? @Masd925
Markus Kiili
@Masd925
Jun 02 2017 07:31
@arjav2002 Yes, all integers <=9007199254740991 are exact.
arjav2002
@arjav2002
Jun 02 2017 07:32
So am I supposed to Math.trunc them? @Masd925
I mean the resultant
Markus Kiili
@Masd925
Jun 02 2017 07:32
@arjav2002 The robust way is to use penny amounts that are integers.
arjav2002
@arjav2002
Jun 02 2017 07:32
@Masd925 so division?
Markus Kiili
@Masd925
Jun 02 2017 07:32
Some rounding schemes or margins of errors can work too.
Dan Couper
@DanCouper
Jun 02 2017 07:33
@JToddFL so reduce takes as an accumulator that empty object (allNames). Then for each name in names, it checks if it exists on the object - if it doesn't, it creates a property for that name, and sets the value to 1. If it does, then it increments that value by one. So if you had [Mary, John, Mary, Frank], the callback would start with the args {} and Mary. Mary is not in that object, so goes into the object. Next name, args are {Mary: 1} and John. John is not in the object, so goes in. Next name, args are {Mary:1, John:1} and Mary again. She's in the object, so the value gets incremented. Next name, args are {Mary:2, John: 1}... and so on
Markus Kiili
@Masd925
Jun 02 2017 07:34
@arjav2002 If you first turn all amounts into pennies and work with them, you avoid precision problems. Then you can turn them back.
arjav2002
@arjav2002
Jun 02 2017 07:34
will 1.01/0.01 will give me 101? @Masd925
101.0?
@Masd925 Thank you. I got it.
CamperBot
@camperbot
Jun 02 2017 07:35
arjav2002 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4188 | @masd925 |http://www.freecodecamp.com/masd925
Proconsul
@proconsu1
Jun 02 2017 07:38
@JToddFL think this might be the prob in your original code: output[array[i][j][0]] = array[i][j][1] i think it shoulda been output[i][array[i][j][0]] = array[i][j][1]
but i wont swear to it until i get to try running it
Rick Willcox
@willcoxDev
Jun 02 2017 07:40
Hi all I am confused how exactly this is a valid function addTogether(2)(3) should return 5.
Markus Kiili
@Masd925
Jun 02 2017 07:41
@willcoxDev addTogether(2) returns a function and (3) calls it.
Rick Willcox
@willcoxDev
Jun 02 2017 07:42
hmm
Jeremy
@JeremyAntonoff
Jun 02 2017 07:43
@proconsu1 i been trying that and i dont think it works. :/
Rick Willcox
@willcoxDev
Jun 02 2017 07:43
weird, does this have a use in the real world, out of curiosity
when would something be written like this
Jeremy
@JeremyAntonoff
Jun 02 2017 07:44
@proconsu1 i tried going that route changing the name of output so it doesn't overwrite firstname etc with the values
Joshua Frias
@Juke-Magic
Jun 02 2017 07:44
heya
can any one tell me why
Jeremy
@JeremyAntonoff
Jun 02 2017 07:45
@DanCouper thank you for the explanation. Does it do that for all strings?
CamperBot
@camperbot
Jun 02 2017 07:45
jtoddfl sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
:cookie: 743 | @dancouper |http://www.freecodecamp.com/dancouper
Joshua Frias
@Juke-Magic
Jun 02 2017 07:45
i cant use
return contacts[i].prop;
Markus Kiili
@Masd925
Jun 02 2017 07:45
@willcoxDev It is useful that functions are objects. They can be stored in variables or for example arrays, and passed into and returned from functions. Functional programming uses that a lot.
Jeremy
@JeremyAntonoff
Jun 02 2017 07:46
still stuck on this :/
function transformEmployeeData(array) {
  // your code here
  var output = {};
  var arrOutput = [];

  for (var i =0; i < array.length; i++) {
    for (var j =0; j < array[i].length; j++) {
       output[array[i][j][0]] = array[i][j][1]


    }
   arrOutput.push(output);
}
return arrOutput;
}
transformEmployeeData([
    [
        ['firstName', 'Joe'], ['lastName', 'Blow'], ['age', 42], ['role', 'clerk']
    ],
    [
        ['firstName', 'Mary'], ['lastName', 'Jenkins'], ['age', 36], ['role', 'manager']
    ]
])
Rick Willcox
@willcoxDev
Jun 02 2017 07:46
@Masd925 ok thanks ill give it another shot
CamperBot
@camperbot
Jun 02 2017 07:46
willcoxdev sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4189 | @masd925 |http://www.freecodecamp.com/masd925
Dan Couper
@DanCouper
Jun 02 2017 07:49
@JToddFL it will work with whatever strings you put into the array - this is a really common challenge, it's normally described as a word count: so you take any text, split it on spaces, then run it through a reduce function that looks like that and it gives you the word count for the text. In this case (adding keys to an object) it has to be strings, as keys in JS are always strings
marcol417
@marcol417
Jun 02 2017 07:50
please can you help me ?
Vedant Kashyap
@vedant15188
Jun 02 2017 07:51
Hey guys is there any specific algorithm to find the Lowest Common Multiple or more than 2 numbers??
Jeremy
@JeremyAntonoff
Jun 02 2017 07:51
@DanCouper I meant is reduce on strings or characters mainly used to count. I know on numbers it can be used to sum them all together for example.
Dan Couper
@DanCouper
Jun 02 2017 07:54
@JToddFL ah, I see. You can use reduce on any array with any values - it is just a way of transforming an array into a single value, of any type - in this case an object. It's extremely powerful, it'll work with any type, it just depends on what you use as the accumulator and how you write the reducer function
Jeremy
@JeremyAntonoff
Jun 02 2017 07:55
@DanCouper thank your sir I really do appreciate it
CamperBot
@camperbot
Jun 02 2017 07:55
jtoddfl sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
:warning: jtoddfl already gave dancouper points
Markus Kiili
@Masd925
Jun 02 2017 07:56
@JToddFL Reduce is the general array iterator. You can do any i