These are chat archives for FreeCodeCamp/HelpJavaScript

24th
Aug 2016
Joseph
@revisualize
Aug 24 2016 00:00
@alaw989 You have this in your code: str.substr(str.length - 1) == target What does it do?
(Note for others: I know the answer. I'm asking to help them solve their own problem.)
Diego Mayer
@Chrono79
Aug 24 2016 00:01
@revisualize I know I know! ;P
Austin Law
@alaw989
Aug 24 2016 00:02
@revisualize i was hoping it found the last character in the string and made it equal to target
Joseph
@revisualize
Aug 24 2016 00:02
@Chrono79 I'm going to smack you with a binary digit.
Carlos Manuel Motin
@carlosmotin81
Aug 24 2016 00:03
@Chrono79 thanks!
CamperBot
@camperbot
Aug 24 2016 00:03
carlosmotin81 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1895 | @chrono79 |http://www.freecodecamp.com/chrono79
Joseph
@revisualize
Aug 24 2016 00:03
@alaw989 But == is a comparison.
Austin Law
@alaw989
Aug 24 2016 00:03
@revisualize so just = ?
@revisualize or ===
Joseph
@revisualize
Aug 24 2016 00:04
@alaw989 How are you supposed to solve your challenge if you don't know what the code you wrote does?
Daniel
@profoundhub
Aug 24 2016 00:05
about @tommygebru
CamperBot
@camperbot
Aug 24 2016 00:05
:cookie: 758 | @tommygebru |http://www.freecodecamp.com/tommygebru
Joseph
@revisualize
Aug 24 2016 00:05
@alaw989 You have this in your code: str.substr(str.length - 1) == target ... What does it do?
Austin Law
@alaw989
Aug 24 2016 00:07
@revisualize extracts the last character of the string and sets it equal to target
Scozzi
@Scozzi
Aug 24 2016 00:08

Too this one took me some time. And I know it works, but I'd love to hear peoples thoughts on it. Is this unnecessarily tedious? ``` // 1 I
// 5 V
// 10 X
// 50 L
// 100 C
// 500 D
// 1000 M
function prepareValue(value,LL,ML,HL) {
var string = "";
switch(value) {
case 1:
string += LL;
break;
case 2:
string += LL.repeat(2);
break;
case 3:
string += LL.repeat(3);
break;
case 4:
string += LL + ML;
break;
case 5:
string += ML;
break;
case 6:
string += ML + LL;
break;
case 7:
string += ML + LL.repeat(2);
break;
case 8:
string += ML + LL.repeat(3);
break;
case 9:
string += LL + HL;
break;
}
return string;
}

function convertToRoman(num) {
var romanNumeral = "";
var remainder;

var Thousands = Math.floor(num / 1000);
console.log(" Thousands :: " + Thousands);
remainder = num % 1000;

var Hundreds = Math.floor(remainder / 100);
console.log(" Hundreds :: " + Hundreds);
remainder = remainder % 100;

var Tens = Math.floor(remainder / 10);
console.log(" Tens :: " + Tens);
remainder = remainder % 10;

var Ones = Math.floor(remainder / 1);
console.log(" Ones :: " + Ones);
remainder = remainder % 1;

romanNumeral +=
"M".repeat(Thousands) +
prepareValue(Hundreds,"C","D","M") +
prepareValue(Tens,"X","L","C") +
prepareValue(Ones,"I","V","X");

return romanNumeral;
}

convertToRoman(891);
```

hmmm why didn't my markup work?
Austin Law
@alaw989
Aug 24 2016 00:09
This message was deleted
Scozzi
@Scozzi
Aug 24 2016 00:09
This message was deleted
This message was deleted
This message was deleted
Joseph
@revisualize
Aug 24 2016 00:13
@alaw989 That isn't correct.
Santiago Gómez
@Sperkajugglite
Aug 24 2016 00:13
hy guys
Austin Law
@alaw989
Aug 24 2016 00:13
@revisualize which part isn't correct
Joseph
@revisualize
Aug 24 2016 00:13
@alaw989 I suggest that you figure out what your code is doing. Because that code bit that I pulled out is part of the answer to solve the problem.
Santiago Gómez
@Sperkajugglite
Aug 24 2016 00:14
do you know how can i do like a pop up window in react?
Diego Mayer
@Chrono79
Aug 24 2016 00:14
@Scozzi edit your post, leave the ```in their own line, shift+enter to insert a carriage-return
Joseph
@revisualize
Aug 24 2016 00:14
@alaw989 This: str.substr(str.length - 1) == target Does NOT do this: extracts the last character of the string and sets it equal to target
@alaw989 Nothing is set. There is no assignment. It only returns true or false it is a comparison.
Santiago Gómez
@Sperkajugglite
Aug 24 2016 00:14
i was thinking on hiding it somehow and the showing it onclick
David Halls
@DavidHalls
Aug 24 2016 00:15
@Sperkajugglite how can you click on something you can't see
Santiago Gómez
@Sperkajugglite
Aug 24 2016 00:15
@Byzgig i mean, i have and edit button and i want a form to pop up :P
David Halls
@DavidHalls
Aug 24 2016 00:16
@Sperkajugglite yeah, you can do that then,
Santiago Gómez
@Sperkajugglite
Aug 24 2016 00:16
i think i can do that with bootstrap too
now that i think so
:thought_balloon:
Joseph
@revisualize
Aug 24 2016 00:18
/collapse-all
Santiago Gómez
@Sperkajugglite
Aug 24 2016 00:18
@revisualize that is for like kidding showing, isnt it?
hiding *
revisualize @revisualize leaves.
Scozzi
@Scozzi
Aug 24 2016 00:20
Thanks @Chrono79
CamperBot
@camperbot
Aug 24 2016 00:20
scozzi sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1896 | @chrono79 |http://www.freecodecamp.com/chrono79
Scozzi
@Scozzi
Aug 24 2016 00:20
// 1    I
// 5    V
// 10   X
// 50   L
// 100  C
// 500  D
// 1000 M
function prepareValue(value,LL,ML,HL) {
  var string = "";
  switch(value) {
    case 1:
      string += LL;
      break;
    case 2:
      string += LL.repeat(2);
      break;
    case 3:
      string += LL.repeat(3);
      break;
    case 4:
      string += LL + ML;
      break;
    case 5:
      string += ML;
      break;
    case 6:
      string += ML + LL;
      break;
    case 7:
      string += ML + LL.repeat(2);
      break;
    case 8:
      string += ML + LL.repeat(3);
      break;
    case 9:
      string += LL + HL;
      break;   
  }
  return string;
}

function convertToRoman(num) {
  var romanNumeral = "";
  var remainder;

  var Thousands = Math.floor(num / 1000);
  console.log(" Thousands  :: " + Thousands);
  remainder = num % 1000;

  var Hundreds = Math.floor(remainder / 100);
  console.log(" Hundreds  :: " + Hundreds);
  remainder = remainder % 100;

  var Tens = Math.floor(remainder / 10);
  console.log(" Tens  :: " + Tens);
  remainder = remainder % 10;

  var Ones = Math.floor(remainder / 1);
  console.log(" Ones  :: " + Ones);
  remainder = remainder % 1;

  romanNumeral +=
    "M".repeat(Thousands) +
    prepareValue(Hundreds,"C","D","M") +
    prepareValue(Tens,"X","L","C") +
    prepareValue(Ones,"I","V","X");

 return romanNumeral;
}

convertToRoman(891);
Addy
@asonder
Aug 24 2016 00:23

Can anyone give me a hint as to why this isn't working? It doesn't seem to be looping properly through the initial array. Thanks in advance. function destroyer(arr) {
var args = Array.prototype.slice.call(arguments);
for (i = 0; i < args[0].length; i++) {
return args.indexOf(args[0][i], 1) !== -1;
}

var newArray = args.filter(destroyer);
return newArray;

}

destroyer(["tree", "hamburger", 53], "tree", 53);

Diego Mayer
@Chrono79
Aug 24 2016 00:24
@Scozzi can be done with less code if that's what you're asking
@asonder you return inside the loop, when it reaches that line, it evaluates args.indexOf(args[0][i], 1) !== -1; and returns a boolean
You have some unwanted? recursion there too
Austin Law
@alaw989
Aug 24 2016 00:27
return (str.substr(-target.length) === target)
Addy
@asonder
Aug 24 2016 00:29
@Chrono79 stupid question: if it returns a boolean does it break the loop?
Diego Mayer
@Chrono79
Aug 24 2016 00:32
@asonder it doesn't matter what's returned, return exits the loop (and the function)
Addy
@asonder
Aug 24 2016 00:32
ooooooohhhh i see
that helps a lot. thanks.
Adole Samuel
@int-elligentSam
Aug 24 2016 00:32
Hello world
CamperBot
@camperbot
Aug 24 2016 00:32

welcome to FreeCodeCamp @samconnor!

Diego Mayer
@Chrono79
Aug 24 2016 00:33
see ya
Addy
@asonder
Aug 24 2016 00:33
thanks @Chrono79
CamperBot
@camperbot
Aug 24 2016 00:33
asonder sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1897 | @chrono79 |http://www.freecodecamp.com/chrono79
celestine001
@celestine001
Aug 24 2016 00:33
Hey everyone. I need help w this..
Liew Xun
@damakuno
Aug 24 2016 00:33
with what
Adole Samuel
@int-elligentSam
Aug 24 2016 00:34
Hello everyone, [sigh] it's been long I have been here. How you all doing
Ken Haduch
@khaduch
Aug 24 2016 00:34
@celestine001 - post your question!
celestine001
@celestine001
Aug 24 2016 00:35
instructions: Update the loop so that if the number 13 is in the array, then the loop stops adding numbers together.
Here’s my code
var sumNumbers = function(array) {
  var sum = 0;

    for(var i = 0; i < array.length; i++) {
   //   sum += array[i];
  {
       if (number.length[i] === 13)
         break;
   {
          return sum;
}
  }
    }
      }
Ken Haduch
@khaduch
Aug 24 2016 00:35
@samconnor - howdy @samconnor - welcome back
celestine001
@celestine001
Aug 24 2016 00:35
sry I’m new at posting code lol obviosly
Ken Haduch
@khaduch
Aug 24 2016 00:36
@celestine001 - which lesson is this?
celestine001
@celestine001
Aug 24 2016 00:37
it’s actually not FCC. It’s a side project as do FCC.
Ken Haduch
@khaduch
Aug 24 2016 00:37
@celestine001 - number.length[i] doesn't seem to be correct for a few reasons - .length() is a method of an array object. You do not have a variable named number - it might be an array if it was defined or declared, but that is probably going to cause a problem.
@celestine001 - oh, okay.
celestine001
@celestine001
Aug 24 2016 00:38
ok.. I’ll check that. Love FCC.. always quick responses & super nice.
Ken Haduch
@khaduch
Aug 24 2016 00:40
@celestine001 - so you should be summing values together, the values must be coming from an array. Your for loop looks find - it should properly process the array. But you need to be adding each value (each number) in the array to the sum - so you should have something like sum += array[i];. But you also have to be checking that array[i] does or doesn't have the value 13 and then stop - return the sum at that point, I'm assuming? But I don't know if you should add the 13 first and then stop, or stop if you find 13 - so you have to be checking something like array[i] === 13 and doing something based on that condition.
Adole Samuel
@int-elligentSam
Aug 24 2016 00:42
@khaduch have you been coding in Javascript for years too?
Austin Law
@alaw989
Aug 24 2016 00:45

Hello. I'm having difficulty understanding why the target.length has to be negative in this algorithm. Anyone?

```function confirmEnding(str, target) {

return str.substr(-target.length) === target;

}

confirmEnding("Bastian", "n");
```

Ken Haduch
@khaduch
Aug 24 2016 00:46
@alaw989 - if you read the documentation on the .substr method, you'll see that if you present a negative value, then it extracts the substr from the end of the string rather than the start of the string. Since you are working with the ending - it's conveniently what you want!
@samconnor - not for years, at least not in JavaScript - I've been coding in other languages for years.
Austin Law
@alaw989
Aug 24 2016 00:48
@khaduch thanks
CamperBot
@camperbot
Aug 24 2016 00:48
alaw989 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 1572 | @khaduch |http://www.freecodecamp.com/khaduch
Adole Samuel
@int-elligentSam
Aug 24 2016 00:58
I kind of find Javascript difficult, do you guys have any links to where I could learn fast
Am from a python background maybe that's why
Alan M.
@Am3ra
Aug 24 2016 00:59
Well, you wont learn much faster in one place or another,
Ken Haduch
@khaduch
Aug 24 2016 00:59
@alaw989 - you're welcome!
Alan M.
@Am3ra
Aug 24 2016 00:59
but look up the book
you dont know JS
Pretty great starting point @samconnor
its also free....
Adole Samuel
@int-elligentSam
Aug 24 2016 01:02
Hmmm...
Alan M.
@Am3ra
Aug 24 2016 01:07
theres like 6 books man
its really worth it, blew me away
Kantra
@removed~kantrakantra
Aug 24 2016 01:10

Hey guys, sorry to keep coming back with iterations of the same question. I'm just truly stuck on this challenge.

Can anybody point out a way I could rejoin this string? Also why isn't it changing char codes (i know I'm srsly stuck on the char codes, pls forgive me) + 13

function stin(long){
    return String.fromCharCode(long.charCodeAt(0) + 13)

}

function name(tru) {
     //return tru.charCodeAt(0);
    return tru.split('').map(stin);


}

name("Gb trg gb gur bgure fvqr");
The string should read "to get to the other side"
pelletierra
@pelletierra
Aug 24 2016 01:12
@kantrakantra wish i could help but im new to java script
what is your output right now?
Kantra
@removed~kantrakantra
Aug 24 2016 01:13
nicolemaj
@nicolemaj
Aug 24 2016 01:13

hi all, I am trying to relate a lookup table to my function. what additional code do I need to "lookup val"??

// 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");

pelletierra
@pelletierra
Aug 24 2016 01:16
@kantrakantra sry dont know enough of the syntax to make it work yet
nicolemaj
@nicolemaj
Aug 24 2016 01:17
how do I relate the lookup table to val and my initial function to return result?
pelletierra
@pelletierra
Aug 24 2016 01:18
anyone know whats wrong here?
var myStr = "FirstLine \n \SecondLine\ \n ThirdLine"; // Change this line
Scozzi
@Scozzi
Aug 24 2016 01:20
@Chrono79 Yea that is what I was getting at Diego. Could you hint at the improvement?
Daniel
@profoundhub
Aug 24 2016 01:22
@jem0113 np
Ken Haduch
@khaduch
Aug 24 2016 01:22
@pelletierra - you have to remove the spaces, per the instructions for the exercise, that's at least one problem.
nicolemaj
@nicolemaj
Aug 24 2016 01:23
hi everyone, sorry to bother, but does anyone have any suggestions for using my var lookup + table to find val of my initial function?
Margaret
@Margaret2
Aug 24 2016 01:23
@nicolemaj use bracket notation to access the val, and set it equal to result
Stephen James
@sjames1958gm
Aug 24 2016 01:23
@nicolemaj https://www.freecodecamp.com/challenges/accessing-objects-properties-with-variables
this challenge showed how to use variables to lookup an object value
pelletierra
@pelletierra
Aug 24 2016 01:24
@khaduch var myStr = "FirstLine\n\SecondLine\\nThirdLine" something like that? Its not printing on 3 lines yet =/
Stephen James
@sjames1958gm
Aug 24 2016 01:24
@kantrakantra add .join("") after map
@pelletierra The second replacement is newline it was supposed to be carriage-return.
Margaret
@Margaret2
Aug 24 2016 01:25
@pelletierra you need backslashes to escape actual backslashes, so just \ in the original text should be changed to \\
Stephen James
@sjames1958gm
Aug 24 2016 01:25
@pelletierra Use single backquotes around your code to prevent markdown from hiding any characters
Aleee
@aamarcatili
Aug 24 2016 01:26
Hello every one..
Margaret
@Margaret2
Aug 24 2016 01:26
and yes it needs \r after Second Line @pelletierra
Stephen James
@sjames1958gm
Aug 24 2016 01:26
@aamarcatili hello
pelletierra
@pelletierra
Aug 24 2016 01:26
the carriage return worked, and for some reason when it copy pasted it got rid of the double backspace O.o
Stephen James
@sjames1958gm
Aug 24 2016 01:26
@pelletierra :+1:
Aleee
@aamarcatili
Aug 24 2016 01:26
N00b here :) with some troubles.. english is not my native languegue so... i apologize in advance
pelletierra
@pelletierra
Aug 24 2016 01:26
i get what new line does but whats carriage return used for?
Aleee
@aamarcatili
Aug 24 2016 01:27
@sjames1958gm hi :D
Stephen James
@sjames1958gm
Aug 24 2016 01:28
@pelletierra Not much anymore - in the old days new line advanced a line and carriage moved the cursor to the beginning of the line.
See how backquotes can keep the backslashes:
var myStr ="FirstLine\\\nSecondLine\\\rThirdLine";
Chris Cullen
@123xylem
Aug 24 2016 01:28
Are we meant to be able to program are own TICTACTOE algorithm???
Ken Haduch
@khaduch
Aug 24 2016 01:28
@pelletierra - if you don't post the code with the markdown coding format, it's hard to see what you actually posted.
Aleee
@aamarcatili
Aug 24 2016 01:28
Some trouble with excersice 141
Stephen James
@sjames1958gm
Aug 24 2016 01:28
@aamarcatili 141 is your progress number - what is the name.
Aleee
@aamarcatili
Aug 24 2016 01:29
convert celsius to fahrenheit
pelletierra
@pelletierra
Aug 24 2016 01:29
var myStr = "FirstLine\n\SecondLine\\rThirdLine";
Stephen James
@sjames1958gm
Aug 24 2016 01:29
@123xylem Start with just having the player play and the computer randomly play - make sure you can detect wins and ties.
@pelletierra `
That is a back quote
pelletierra
@pelletierra
Aug 24 2016 01:29
@sjames1958gm is there a secret to making the code not be plain text
Stephen James
@sjames1958gm
Aug 24 2016 01:30
@pelletierra Put the quote next to the 1 key on either end
Chris Cullen
@123xylem
Aug 24 2016 01:30
@sjames1958gm so after player click use function (cpu Random click)
something like that
Kantra
@removed~kantrakantra
Aug 24 2016 01:30

@sjames1958gm Ok that works but why is the length of the string changing before and after return tru.split('').map(stin).join('');?

https://repl.it/CqtA/1

pelletierra
@pelletierra
Aug 24 2016 01:30
var myStr = "FirstLine\n\\SecondLine\\\nThirdLine"
Stephen James
@sjames1958gm
Aug 24 2016 01:30
@123xylem That is what I did, just picked a number between 0 and 8
pelletierra
@pelletierra
Aug 24 2016 01:30
oh perfect, ty
Mike
@MikeJSchorah
Aug 24 2016 01:31
Could someone please let me know how to change the background color with the click of a button? I think it has something to do with document.getElementById, but I'm not sure what property to use.
Stephen James
@sjames1958gm
Aug 24 2016 01:31
@pelletierra Off to the left there is a little M and down arrow - click that to see mark up syntax
Aleee
@aamarcatili
Aug 24 2016 01:31

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

fahrenheit=+32;

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

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

Ken Haduch
@khaduch
Aug 24 2016 01:31
@pelletierra - you don't have the correct escape sequence for carriage return
pelletierra
@pelletierra
Aug 24 2016 01:31
'''var myStr = "FirstLine\n\SecondLine\\nThirdLine"''''
CamperBot
@camperbot
Aug 24 2016 01:32
:bulb: to format code use backticks! ``` more info
Stephen James
@sjames1958gm
Aug 24 2016 01:32
@pelletierra Use three backquotes, shift-enter, paste, shift-enter, three backquotes and enter to get the black backgroound
pelletierra
@pelletierra
Aug 24 2016 01:32
var myStr = "FirstLine\n\SecondLine\\nThirdLine"
'''
CamperBot
@camperbot
Aug 24 2016 01:32
:bulb: to format code use backticks! ``` more info
Ken Haduch
@khaduch
Aug 24 2016 01:32
help format
CamperBot
@camperbot
Aug 24 2016 01:32
no wiki entry for: format
pelletierra
@pelletierra
Aug 24 2016 01:33
'''
var myStr = "FirstLine\n\SecondLine\\nThirdLine"
CamperBot
@camperbot
Aug 24 2016 01:33
:bulb: to format code use backticks! ``` more info
Stephen James
@sjames1958gm
Aug 24 2016 01:33
@pelletierra Those are single quotes
Ken Haduch
@khaduch
Aug 24 2016 01:33
help code
CamperBot
@camperbot
Aug 24 2016 01:33
no wiki entry for: code
Stephen James
@sjames1958gm
Aug 24 2016 01:33
`
pelletierra
@pelletierra
Aug 24 2016 01:33
rip sry lol
Stephen James
@sjames1958gm
Aug 24 2016 01:33
@aamarcatili Use the formula on the left, substitute the parameter celsius for C and the variable fahrenheit for F
pelletierra
@pelletierra
Aug 24 2016 01:34
var myStr = "FirstLine\n\\SecondLine\\\nThirdLine"
Stephen James
@sjames1958gm
Aug 24 2016 01:35
@pelletierra :clap:
pelletierra
@pelletierra
Aug 24 2016 01:35
makes sense now, first time typing code in chat ;p
Margaret
@Margaret2
Aug 24 2016 01:35
@aamarcatili you have to take celsius, multiply it by 9/5, add 32 to it, and then set that result equal to fahrenheit
Aleee
@aamarcatili
Aug 24 2016 01:35
@sjames1958gm wich formula ?
Raul Calzado
@raulprobeatz
Aug 24 2016 01:35

Hello guys! I would like display data from a textbox in my table. Let me explain it better: when I input the value (a code that is in my job) in the textbox, I want it to display immediately in the table

Here is the code:

<script>
//Load data to table
$('.form-control').change(function()
{
var dataBianual = $('#txtInput').val();
var newRow = '<tr><td>' + dataBianual + '</td></tr>';
$('#bTable tr:last').after(newRow);
});

</script>
<!-- Bootstrap -->
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">

</head>

<body style='margin-top:0;'>

<div id="principal" style="width:760px;height:500px;margin-left:auto;margin-right:auto;" class="container-fluid">

        <div style='width:760px;height:100px;'><h1>Recibo de Bianuales</h1></div>
        <div class="row">
            <div class="col-sm-2">
                <label for='txtInput'>ChildKey</label>
            </div>
            <div class="col-sm-3">
                <input type="text" id="txtInput" onchange="MensajeBarcode()" class="form-control">
            </div>

            <!-- <button id="boton" onclick="MensajeBarcode()">Mensaje</button> -->
            <div class="col-sm-10">
                <button style='margin-top:20px;' onclick="EjecutaAjaxGeneraRecibo()" type="button" class="btn btn-primary">Generar Recibo</button>
                <!-- <button style='margin-top:10px;' onclick="EjecutaAjaxGeneraRecibo()">Generar Recibo</button> -->
            </div>
            <div class="col-sm-3">
                    <div class="table-responsive">
                        <table id="bTable" style='margin-top:20px;' class="table-bordered table-condensed table table-hover table-striped">
                            <thead>
                                <tr>
                                    <th>Bianuales Recibidos</th>
                                </tr>
                            </thead>
                    </div>
                </div>
        </div>

</div>
Can you help me out?
Stephen James
@sjames1958gm
Aug 24 2016 01:35
@aamarcatili F = C * 9 / 5 + 32
Chris Cullen
@123xylem
Aug 24 2016 01:36
@sjames1958gm how can i say something like remove A from choice array [a b c d e f] after a gets clicked?
Margaret
@Margaret2
Aug 24 2016 01:36
This message was deleted
Chris Cullen
@123xylem
Aug 24 2016 01:36
if (user=="X") {
   userX=1 ; 
  $(".box").on('click', function(){
  var id = $(this).attr('id');
  switch(id){ 
    case "a":
answer.push("A");  
//choices[a].delete?   
  break;
    case "b":
answer.push("B");         break;
   case "c":
answer.push("C");       break;   
   case "d":
answer.push("D");       break;
Stephen James
@sjames1958gm
Aug 24 2016 01:37
@123xylem Maybe replace with something. I started with an array of empty strings and then replaced with "X" "O" when a play was made
Chris Cullen
@123xylem
Aug 24 2016 01:37
case a .delete?
Tatiana Perry
@tjperry07
Aug 24 2016 01:38
This message was deleted
Stephen James
@sjames1958gm
Aug 24 2016 01:38
@123xylem splice? (delete will leave a null there)
@tjperry07 collection has no property ["2468"].album it has a property 2648 and collection["2468"] has a property "album"
Tatiana Perry
@tjperry07
Aug 24 2016 01:39
for record collection, can anyone give some direction as to why this doesn't return true.
var collection = {
    "2548": {
      "album": "Slippery When Wet",
      "artist": "Bon Jovi",
      "tracks": [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    "2468": {
      "album": "1999",
      "artist": "Prince",
      "tracks": [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    "1245": {
      "artist": "Robert Palmer",
      "tracks": [ ]
    },
    "5439": {
      "album": "ABBA Gold"
    }
};

// var testing = collection["2468"].tracks;
var testing = collection.hasOwnProperty(["2468"].album);
console.log(testing);
Mike
@MikeJSchorah
Aug 24 2016 01:39
@sjames1958gm I checked it out. Are there any articles related to onclick? I'm trying to change the background color with the click of a button for Random Quote Machine.
Aleee
@aamarcatili
Aug 24 2016 01:40
@Margaret2
should I create another var called Celcius ?
Stephen James
@sjames1958gm
Aug 24 2016 01:40
document.getElementById("myelement").on("click", function() { //here });
@aamarcatili celsius is passed in the function definition use that
Tatiana Perry
@tjperry07
Aug 24 2016 01:40
@sjames1958gm I tried that. It still gave me false. collection.hasOwnProperty(collection["2468"].album);
Ken Haduch
@khaduch
Aug 24 2016 01:41
@tjperry07 - sure. You are not properly accessing the collection... it would have to be collection["2468"] (or perhaps collection[2468] then .album- I guess it depends on what you're trying to access... looks like you want the album property of the particular record that you have the ID of?
Stephen James
@sjames1958gm
Aug 24 2016 01:41
@tjperry07 collection.hasOwnProperty("2468");
Aleee
@aamarcatili
Aug 24 2016 01:41
not getting it :worried:
Stephen James
@sjames1958gm
Aug 24 2016 01:42
@aamarcatili When the function gets called, the parameter celsius will be set to the temperature to convert
Tatiana Perry
@tjperry07
Aug 24 2016 01:42
Not checking for property 2486. I am checking if there is an the album in 2486
basically I need to know if this collection["2468"].album returns true.
Stephen James
@sjames1958gm
Aug 24 2016 01:43
@tjperry07 Then collection["2468"].hasOwnProperty("album") the left of the . has to be the object that has the property
Aleee
@aamarcatili
Aug 24 2016 01:44

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

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

??
Tatiana Perry
@tjperry07
Aug 24 2016 01:44
@sjames1958gm Thank you! I was thinking I needed to put everything in hasOwnProperty
CamperBot
@camperbot
Aug 24 2016 01:44
tjperry07 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2823 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Aug 24 2016 01:44
@aamarcatili F = C * 9 / 5 + 32 replace C with celsius (which is passed to the function) and F with fahrenheit.
Tatiana Perry
@tjperry07
Aug 24 2016 01:44
@khaduch I got it. Thank you!
CamperBot
@camperbot
Aug 24 2016 01:44
tjperry07 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 1573 | @khaduch |http://www.freecodecamp.com/khaduch
Stephen James
@sjames1958gm
Aug 24 2016 01:45
@tjperry07 :+1:
Luis Salgado
@lesalgado47
Aug 24 2016 01:45
why this no work , conceptually?
for(i = 0; i < contacts.length; i++){
    if(contacts.length == i && (firstName !== contacts[i].firstName)){
    console.log(i + " " + firstName + " " + prop);
    }
Margaret
@Margaret2
Aug 24 2016 01:45
@aamarcatili what they said^^
Stephen James
@sjames1958gm
Aug 24 2016 01:45
@lesalgado47 i will never be === to contact.length, your for loop prevents it
Zachary Bennett
@zbennett10
Aug 24 2016 01:45
function addTogether() {
   var firstNum = arguments[0];

  if (arguments.length === 2 && typeof arguments[0] === 'number' && typeof arguments[1] === 'number') {
      return arguments[0] + arguments[1];
      }

  else if ( arguments.length === 1 && typeof arguments === 'number' ) {

   var sumTwoAnd = function (num) {
    return firstNum + num;
  };
     return sumTwoAnd();  
  }

  else if (typeof arguments !== 'number') {
    return undefined;
  }

}

addTogether(2);
So when this function only has one argument, it doesn't work.. I'm working on the Arguments Optional algorithm. Thanks for the help
Luis Salgado
@lesalgado47
Aug 24 2016 01:46
@sjames1958gm contact.length = 4
Stephen James
@sjames1958gm
Aug 24 2016 01:46
@zbennett10 You are returning the result of calling sumTwoAnd
@lesalgado47 Yes, but your for loop says i will only be 0 - 3 inside the loop
@zbennett10 Just return the function (don't call it)
Zachary Bennett
@zbennett10
Aug 24 2016 01:48
@sjames1958gm thanks! OK I changed that and it still didnt work
CamperBot
@camperbot
Aug 24 2016 01:48
:star2: 2824 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
zbennett10 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
Luis Salgado
@lesalgado47
Aug 24 2016 01:48
@sjames1958gm for(i = 0; i < contacts.length; i++){
if(((contacts.length - 1) == i) && (firstName !== contacts[i].firstName)){
console.log(i + " " + firstName + " " + prop);
}
}
for(i = 0; i < contacts.length; i++){
    if(((contacts.length - 1) == i) && (firstName !== contacts[i].firstName)){
    console.log(i + " " + firstName + " " + prop);
    }
}
Stephen James
@sjames1958gm
Aug 24 2016 01:49
@zbennett10 Which tests does it fail?
Aleee
@aamarcatili
Aug 24 2016 01:49
@sjames1958gm thaksss so much didn't catch it until just now :D
Mike
@MikeJSchorah
Aug 24 2016 01:49
document.getElementById("myelement").on("click", function() { //here });
@sjames1958gm Could you please explain how this breaks down. I don't remember. I know that document is the DOM. Should I use div since I'm trying to change the color of the background? Would "my element" be "div" as well? I'm confused at what "on" means. I understand it's the class, but is it just made up? And what type of function should I be using?
Stephen James
@sjames1958gm
Aug 24 2016 01:49
@aamarcatili :+1:
Luis Salgado
@lesalgado47
Aug 24 2016 01:49
@sjames1958gm has got it going on
Zachary Bennett
@zbennett10
Aug 24 2016 01:49
@sjames1958gm addTogether(2)(3) should return 5.
and addTogether(2)([3])
Mike
@MikeJSchorah
Aug 24 2016 01:50
@lesalgado47 Agree. @sjames1958gm is the king of code.
Stephen James
@sjames1958gm
Aug 24 2016 01:50
@zbennett10 The second is because you missed one requirement of checking the parameter in you returned function - the first should work - can you post again.
document.getElementById("myelement").on("click", function() { //here });
document is the DOM
getElementById will return the HTML element with the id "myelement"
.on is the function that attaches a handler
"click" means wait for "click" and then finally the function is where you put your code to change the background
Luis Salgado
@lesalgado47
Aug 24 2016 01:51
@MikeJSchorah idk what he even said there in that last post
Zachary Bennett
@zbennett10
Aug 24 2016 01:51
function addTogether() {
   var firstNum = arguments[0];

  if (arguments.length === 2 && typeof arguments[0] === 'number' && typeof arguments[1] === 'number') {
      return arguments[0] + arguments[1];
      }

  else if ( arguments.length === 1 && typeof arguments === 'number' ) {

   var sumTwoAnd = function (num) {
    return firstNum + num;
  };
     return sumTwoAnd;  
  }

  else if (typeof arguments !== 'number') {
    return undefined;
  }

}

addTogether(2);
sam-s4s
@sam-s4s
Aug 24 2016 01:52

Hi all ^_^

Quick question...

To convert a JS object to a JSON string, I can use JSON.stringify()

Is there anything similar for converting to an XML string instead?

Stephen James
@sjames1958gm
Aug 24 2016 01:52
@zbennett10 Look at your if right before you return the function.
@sam-s4s There might be a library for that. But not a built in like JSON
Zachary Bennett
@zbennett10
Aug 24 2016 01:53
@sjames1958gm ok thanks :smile:
CamperBot
@camperbot
Aug 24 2016 01:53
zbennett10 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: zbennett10 already gave sjames1958gm points
Stephen James
@sjames1958gm
Aug 24 2016 01:53
@lesalgado47 Not sure what you are trying to accomplish?
Ken Haduch
@khaduch
Aug 24 2016 01:53
sam-s4s
@sam-s4s
Aug 24 2016 01:53
darn, I was hoping there'd be something built in...
Mike
@MikeJSchorah
Aug 24 2016 01:54
Thanks @sjames1958gm What should my corresponding HTML look like if I'm only changing the background color?
CamperBot
@camperbot
Aug 24 2016 01:54
mikejschorah sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2825 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Aug 24 2016 01:54
XML - because some people hate programmers
sam-s4s
@sam-s4s
Aug 24 2016 01:54
Yeah, looks like you have to build up and XML DOM tree, and then convert that into a string...
Stephen James
@sjames1958gm
Aug 24 2016 01:56
@MikeJSchorah
document.getElementById("myelement").style.backgroundColor = "#eee";
@MikeJSchorah I would go to jsbin and experiment.
Suzanne Atkinson
@AdventureBear
Aug 24 2016 01:57
woohoo, I finally finished the basic javascript section including all the new stuff
Stephen James
@sjames1958gm
Aug 24 2016 01:57
@AdventureBear :+1:
Ken Haduch
@khaduch
Aug 24 2016 01:58
@AdventureBear - :clap:
Suzanne Atkinson
@AdventureBear
Aug 24 2016 01:59
@sjames1958gm , @khaduch thanks!!
CamperBot
@camperbot
Aug 24 2016 01:59
adventurebear sends brownie points to @sjames1958gm and @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2826 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
:star2: 1574 | @khaduch |http://www.freecodecamp.com/khaduch
Suzanne Atkinson
@AdventureBear
Aug 24 2016 01:59
back to trudging through the advanced algorithms
Zachary Bennett
@zbennett10
Aug 24 2016 02:00
@sjames1958gm yeah would you mind pointing me a little closer in the right direction? I looked at the "if" right before i return the function and I don't see anything
@sjames1958gm i appreciate you helping me without straight up giving me the answer.. i really want to understand this stuff
Stephen James
@sjames1958gm
Aug 24 2016 02:00
@zbennett10 typeof arguments === "number"
what is the the typeof arguments
Ken Haduch
@khaduch
Aug 24 2016 02:01
@zbennett10 - I think that you are erroneously checking typeof arguments - when you should be checking the individual elements of the arguments "array"...
Thomas Noe
@t3h2mas
Aug 24 2016 02:01
yep
Stephen James
@sjames1958gm
Aug 24 2016 02:01
@khaduch :+1:
Zachary Bennett
@zbennett10
Aug 24 2016 02:02
@sjames1958gm ok I changed that to check the actual postion inside the arguments object and the first test works! thanks
CamperBot
@camperbot
Aug 24 2016 02:02
zbennett10 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: zbennett10 already gave sjames1958gm points
Joseph
@revisualize
Aug 24 2016 02:02
Hello!
Zachary Bennett
@zbennett10
Aug 24 2016 02:02
the typeof arguments would be an object wouldnt it
Thomas Noe
@t3h2mas
Aug 24 2016 02:02
sup @revisualize
arguments is an object.
Joseph
@revisualize
Aug 24 2016 02:03
Just at the Seattle FreeCodeCamp Meetup.
Zachary Bennett
@zbennett10
Aug 24 2016 02:03
ok totally makes sense now
Thomas Noe
@t3h2mas
Aug 24 2016 02:03
Right on @revisualize :)
Mike
@MikeJSchorah
Aug 24 2016 02:03
@revisualize Hello. FCC has not been the same since you left.
Didn't know there were FCC Meetups. Thanks @revisualize
CamperBot
@camperbot
Aug 24 2016 02:03
mikejschorah sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1707 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Aug 24 2016 02:04
@MikeJSchorah I left?
Thomas Noe
@t3h2mas
Aug 24 2016 02:05
interesting question, what would you guys use to keep track of arguments of a wrapped function
Mike
@MikeJSchorah
Aug 24 2016 02:06
A year ago, I was contacted by CodeCademy to organize a CodeCademy meetup. The problem was that CodeCademy was so unorganized themselves that I said to hell with it
Thomas Noe
@t3h2mas
Aug 24 2016 02:06
there's some stuff on the wiki about meetups
Mike
@MikeJSchorah
Aug 24 2016 02:07
@t3h2mas Could it be called in this chat?
Thomas Noe
@t3h2mas
Aug 24 2016 02:07
i'll poste when i find it
post**
Kantra
@removed~kantrakantra
Aug 24 2016 02:07

Ok, I'm back again. I feel I'm in the final stages of understanding this solution. I'm obviously a beginner so this has been tricky for me and I've been stuck on this exercise for far too long but I have one last question here. In this solution:

function rot13(str) {
  return str.split('').map.call(str, function(char) {  //What exactly is .call doing and what is a simple way of explaining what .call() does in general. The MDN has left me confused.

      x = char.charCodeAt(0);

      if (x < 65 || x > 90) {
        return String.fromCharCode(x);  
      }

      else if (x < 78) {
        return String.fromCharCode(x + 13);
      }

      return String.fromCharCode(x - 13);

    }).join(''); 

}

What exactly is .call doing and what is a simple way of explaining what .call() does in general. The MDN has left me confused.

Diego Mayer
@Chrono79
Aug 24 2016 02:11
@Scozzi you could use a while loop and decrease the number adding the proper letters in the process
Joseph
@revisualize
Aug 24 2016 02:11
ROT!
Thomas Noe
@t3h2mas
Aug 24 2016 02:12
ceasar would be pleased
Joseph
@revisualize
Aug 24 2016 02:12
Which Caesar got stabbed in the back?
Thomas Noe
@t3h2mas
Aug 24 2016 02:12
is there a way to access another function's arguments object?
Joseph
@revisualize
Aug 24 2016 02:13
I don't think so.
arguments is scoped to the function.
Thomas Noe
@t3h2mas
Aug 24 2016 02:13
right, curious if there's a way to rig it
John
@tertiaryidentifier
Aug 24 2016 02:14
mightily proud of my javascript calculator :)
@t3h2mas , you might want to consider nesting the functions and passing arguments
Stephen James
@sjames1958gm
Aug 24 2016 02:15
@zbennett10 :)
@MikeJSchorah
document.getElementById("myelement").style.backgroundColor = "#555";
Thomas Noe
@t3h2mas
Aug 24 2016 02:15
right now i'm thinking about passing a second argument to the wrapper to hold the arguments
Joseph
@revisualize
Aug 24 2016 02:16
@tertiaryidentifier I'm going to try some math. 5 * - 5 = ... Let's see what happens!
IT WORKS!
John
@tertiaryidentifier
Aug 24 2016 02:17
yeah the "minus" shouldn't be used for declarations of negative, I think ...
but uhh ... glad it works?
Stephen James
@sjames1958gm
Aug 24 2016 02:17
@kantrakantra I am not sure the call is needed there, split('') results in an array which has map. If you don't do call then str should be removed from the call.
Paulo Alexandre
@PauloFurtunatoAlexandre
Aug 24 2016 02:18
what am I doing wrong?

function caseInSwitch(val) {
var answer = "";
// Only change code below this line
switch (num) {
case 1:
console.log("alpha");
break;

case 2:
console.log("beta");
break;

case 3:
console.log("gamma");
break;

default:
console.log("delta");

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

// Change this value to test
caseInSwitch(1);
caseInSwitch(2);
caseInSwitch(3);
caseInSwitch(4);

I don't know why should I use this function there... if the exercise is asking for use case switch
Stephen James
@sjames1958gm
Aug 24 2016 02:20
@gigaPaul You should be testing val not num also console.log will not return the value - assign values to answer for return
Paulo Alexandre
@PauloFurtunatoAlexandre
Aug 24 2016 02:20
let me see
Joseph
@revisualize
Aug 24 2016 02:20
@gigaPaul You're assigning var answer = ""; then you return answer; without modifying answer .... Ergo, you're just returning ""
Paulo Alexandre
@PauloFurtunatoAlexandre
Aug 24 2016 02:22
but my question is... why should I use this inside the function
Joseph
@revisualize
Aug 24 2016 02:23
Why would you use a switch inside of a function?
Paulo Alexandre
@PauloFurtunatoAlexandre
Aug 24 2016 02:23
this link is given in the exercise... there are some examples... they can do the test without any function
Thomas Noe
@t3h2mas
Aug 24 2016 02:23
instead of multiple if elses
Joseph
@revisualize
Aug 24 2016 02:23
Why would you use an if/else inside of a function?
Paulo Alexandre
@PauloFurtunatoAlexandre
Aug 24 2016 02:23
okay...
Thomas Noe
@t3h2mas
Aug 24 2016 02:23
it's clearer than 10 if/elses
Joseph
@revisualize
Aug 24 2016 02:23
Why would you use a for loop inside of a function?
Thomas Noe
@t3h2mas
Aug 24 2016 02:23
and easier to write
Joseph
@revisualize
Aug 24 2016 02:23
Why would you use a while loop inside of a function?
Paulo Alexandre
@PauloFurtunatoAlexandre
Aug 24 2016 02:24
to test something
Kantra
@removed~kantrakantra
Aug 24 2016 02:27

@sjames1958gm Like this? https://repl.it/CqtA/2 (this obviously isn't correct)
I am also interested in the purpose of .call(). Idk if anyone would be interested in explaining it in simple terms.

I understand everything else in the solution except lines 2-4.

Thank you

CamperBot
@camperbot
Aug 24 2016 02:27
kantrakantra sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2827 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
BrianR
@brianrudloff
Aug 24 2016 02:31
Why is this not reversing the string?
unction reverseString(str) {
str.split('').reverse().join('');
return str;
}
Paulo Alexandre
@PauloFurtunatoAlexandre
Aug 24 2016 02:31

function caseInSwitch(val) {
var answer = val;
// Only change code below this line
switch (val) {
case 1:
return "alpha";
break;

case 2:
return "beta";
break;

case 3:
return "gamma";
break;

default:
return "delta";

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

// Change this value to test
caseInSwitch(1);
caseInSwitch(2);
caseInSwitch(3);
caseInSwitch(4);

Thomas Noe
@t3h2mas
Aug 24 2016 02:32
@brianrudloff it's immutable
Paulo Alexandre
@PauloFurtunatoAlexandre
Aug 24 2016 02:32
how do you guys put the black screen directly here?
Thomas Noe
@t3h2mas
Aug 24 2016 02:32
it returns a new string, instead of using a side effect to change str itsself
Diego Mayer
@Chrono79
Aug 24 2016 02:32
@gigaPaul ``` before and after your code in their onw line
LPR-309
@LPR-309
Aug 24 2016 02:33
@gigaPaul Multi-lined code? Start with triple `, shift-enter, end with triple 1
  • `
Diego Mayer
@Chrono79
Aug 24 2016 02:33
```js //optionally js/css/html for better coloring
code
```
Thomas Noe
@t3h2mas
Aug 24 2016 02:33
var newReversedString = str.reverse();
Kevin
@KevinFleming
Aug 24 2016 02:34
hi anyone want to help with some javascript escaping?
BrianR
@brianrudloff
Aug 24 2016 02:34
@t3h2mas Thanks :)
CamperBot
@camperbot
Aug 24 2016 02:34
brianrudloff sends brownie points to @t3h2mas :sparkles: :thumbsup: :sparkles:
:cookie: 373 | @t3h2mas |http://www.freecodecamp.com/t3h2mas
Ken Haduch
@khaduch
Aug 24 2016 02:34
@gigaPaul - you are doing a number of return statements in your code - but it looks like they have a line that you aren't supposed to change return answer; - which implies that you should, perhaps, be setting the variable answer to the values within the case statements? And not returning in all of those places?
Paulo Alexandre
@PauloFurtunatoAlexandre
Aug 24 2016 02:35
function caseInSwitch(val) {
  var answer = val;
  // Only change code below this line
  switch (val) {
  case 1:
    return "alpha";
  break;

  case 2:
    return "beta";
  break;

  case 3:
    return "gamma";
  break;

  default:
    return "delta";

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

// Change this value to test
caseInSwitch(1);
caseInSwitch(2);
caseInSwitch(3);
caseInSwitch(4);
`
Thomas Noe
@t3h2mas
Aug 24 2016 02:35
closer
Diego Mayer
@Chrono79
Aug 24 2016 02:35
@gigaPaul add a carriage-return after the first ``` (with shift+enter)
Thomas Noe
@t3h2mas
Aug 24 2016 02:36
perhaps think about why they're returning answer. maybe there's a way to work with their code
Paulo Alexandre
@PauloFurtunatoAlexandre
Aug 24 2016 02:40
okay... worked...
now... let me go back to the answers
but how can I give the answer without assigning the val to it?
I don't get it
Thomas Noe
@t3h2mas
Aug 24 2016 02:42
assign the value to answer then return it
(hint, only use one return)
CamperBot
@camperbot
Aug 24 2016 02:42
Set a bonfire to talk about with bonfire name
mamun
@fsdmamun
Aug 24 2016 02:45
paulo
Joseph
@revisualize
Aug 24 2016 02:47
@camperbot Why you broken?
Chris Cullen
@123xylem
Aug 24 2016 02:57
@123xylem
http://codepen.io/123xylem/pen/JKqYZY?editors=0011
I disabled additional dialogue openings and my prompt doesnt work again... :(
Ive turned chrome on and off and reset settings :(
Is my prompt wrong or something?
Chad Powell
@cjpowellaz
Aug 24 2016 02:58
help Mutations
CamperBot
@camperbot
Aug 24 2016 02:58
no wiki entry for: mutations
Chad Powell
@cjpowellaz
Aug 24 2016 03:00
For the Mutations challenge, I can get it to either return False for the False answers or True for the True answers but I can't get it to check for both.

function mutation(arr) {
var newArray;

var arrayString = arr.toString();
var arrayLowerString= arrayString.toLowerCase();
var arrayLower = arrayLowerString.split(",");

newArray = arrayLower.indexOf(arrayLower[0], arrayLower1) !== -1;
return newArray;
}

mutation(["hello", "hey"]);

Paulo Alexandre
@PauloFurtunatoAlexandre
Aug 24 2016 03:01
@t3h2mas thanks!
CamperBot
@camperbot
Aug 24 2016 03:01
gigapaul sends brownie points to @t3h2mas :sparkles: :thumbsup: :sparkles:
:cookie: 374 | @t3h2mas |http://www.freecodecamp.com/t3h2mas
Michael Noronha
@mtn
Aug 24 2016 03:05
Quick general review question: the arguments object allows you to access arguments passed in the function call, even if the number of parameters the function "accepts" is fewer than the number of parameters passed
(Right?)
So if I have exampleFunction(a) and I call exampleFunction(a,b,c)
Joseph
@revisualize
Aug 24 2016 03:06
@michaeltnoronha Correct.
Michael Noronha
@mtn
Aug 24 2016 03:06
exampleFunction(a) will run, and all three arguments passed will be accessible within the function as arguments[0], 1, and [2]
Joseph
@revisualize
Aug 24 2016 03:06
The thing you need to understand is that arguments is an object scoped to the function. Each function and sub function has its own arguments.
Michael Noronha
@mtn
Aug 24 2016 03:07
@revisualize yup yup, got it. Thanks for confirming
CamperBot
@camperbot
Aug 24 2016 03:07
michaeltnoronha sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1709 | @revisualize |http://www.freecodecamp.com/revisualize
Michael Noronha
@mtn
Aug 24 2016 03:07
@revisualize wondering if there's something similar in ruby
Joseph
@revisualize
Aug 24 2016 03:07
I'll let you know in 5 years when I learn Ruby.
Michael Noronha
@mtn
Aug 24 2016 03:08
@revisualize ahaha :)
Michael Noronha
@mtn
Aug 24 2016 03:08
Actually, I think a better way to do it will be to set values to nil and change them only if hhold something different
While will work (better, maybe) so long as the api doesn't reassign fields if a nil value is passed
Thomas Noe
@t3h2mas
Aug 24 2016 03:09
var a = myArg || 'default string'; was an old way to do it in js
looks like you can do def some_method(*args) in ruby
Michael Noronha
@mtn
Aug 24 2016 03:10
@t3h2mas thanks very helpful link
CamperBot
@camperbot
Aug 24 2016 03:10
michaeltnoronha sends brownie points to @t3h2mas :sparkles: :thumbsup: :sparkles:
:cookie: 375 | @t3h2mas |http://www.freecodecamp.com/t3h2mas
Michael Noronha
@mtn
Aug 24 2016 03:10
includes the implementation for the ideas I was talking about :)
Thomas Noe
@t3h2mas
Aug 24 2016 03:10
:+1:
Michael Noronha
@mtn
Aug 24 2016 03:11
ugggghhhh I have a love-hate relationship with this gitter client. it's nice and pretty but slow af. i've experimented with gitter via irc but that strips out a lot
Chris Cullen
@123xylem
Aug 24 2016 03:11
var move= Math.floor(Math.random()*choices.length);
I found the prompt Stopper in my program!...Any idea why this would stop my prompt from working?
http://codepen.io/123xylem/pen/JKqYZY?editors=0010
Michael Noronha
@mtn
Aug 24 2016 03:11
for example, no multiline text
(at least in hexchat)
Thomas Noe
@t3h2mas
Aug 24 2016 03:12
it's a trade off
t3h2mas @t3h2mas is on weechat
tyl-er
@tyl-er
Aug 24 2016 03:17

Need some help
Check if a string (first argument, str) ends with the given target string (second argument, target).

function confirmEnding(str, target) {
var end = target.length;
var x = str.lenght;
var y = x - end;
var res = str.substring(y, x);

if (res == target) {
return true;
} else {
return false;
}
}

confirmEnding("Open sesame", "same");

The "y" variable doesn't work.

BrianR
@brianrudloff
Aug 24 2016 03:19

Any better ideas for this function to return a 'true' boolean when a palindrome is inserted...

function palindrome(str) {
var newstr = str.replace(/![A-Z]/g, "").toLowerCase;
if (newstr === newstr.split('').reverse().join('')) {
return true;
}
}

Joseph
@revisualize
Aug 24 2016 03:21
@brianrudloff you're using ! in your regex. That isn't correct.
You're also removing all lowercase letter and all numbers.
@brianrudloff This needs to be fixed:
if (newstr === newstr.split('').reverse().join('')) {
return true;
}
You're only returning true. You're not returning false.
Chris Cullen
@123xylem
Aug 24 2016 03:23
var choices=[a b c d etcetc];
var move= choices[Math.floor(Math.random()*choices.length)];

 <div class="box" id="a"></div>
      <div class="box" id="b"></div>
      <div class="box" id="c"></div>
      <div class="box" id="d"></div>
      <div class="box" id="e"></div>
      <div class="box" id="f"></div>
      <div class="box" id="g"></div>
      <div class="box" id="h"></div>
      <div class="box" id="i"></div>   //IS THERE A WAY OF SELECTING one of the  ids or .box INSTEAD of one element from choices array.?
IM trying to get an array of potential moves.
Is there a way I can do this via my box class or Ids instead of through a made up array which i have to convert?
Joseph
@revisualize
Aug 24 2016 03:23
That also a really crappy way of doing it.
@123xylem What is choices.length?
BrianR
@brianrudloff
Aug 24 2016 03:24
how do I make a new string with spaces and non-alpha numeric characters removed?
Joseph
@revisualize
Aug 24 2016 03:24
@brianrudloff Regex.
Ari Winokur
@ariwinokur
Aug 24 2016 03:25
I'm working on the "Profile Lookup" challenge, but I'm not sure how to even start. Feeling a little overwhelmed. Can someone give me some starting points to get things going?
tyl-er
@tyl-er
Aug 24 2016 03:25
Just wondering how I can get my y variable to work or if i need to try something else.
Joseph
@revisualize
Aug 24 2016 03:25
@123xylem The answer is SyntaxError: Unexpected identifier
@ariwinokur Sure!
Greg Duncan
@GregatGit
Aug 24 2016 03:26
@tyl-er you have a typo var x = str.lenght; th not ht
Chris Cullen
@123xylem
Aug 24 2016 03:27
@revisualize choices is a made up array where I choose one of the elements randomly and then convert that to the board as a cpu move.. Id rather pick one of the board boxes randomly and let that click itself...
Ari Winokur
@ariwinokur
Aug 24 2016 03:27
Thanks @revisualize! I will look over that Gist!
CamperBot
@camperbot
Aug 24 2016 03:27
ariwinokur sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1710 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Aug 24 2016 03:27
@123xylem Do you have more variables?
tyl-er
@tyl-er
Aug 24 2016 03:28
@GregatGit Thanks lol
CamperBot
@camperbot
Aug 24 2016 03:28
tyl-er sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:cookie: 744 | @gregatgit |http://www.freecodecamp.com/gregatgit
Joseph
@revisualize
Aug 24 2016 03:28
@123xylem You don't have an a variable. nor do you have a b variable. Nor do you have a c variable.
@123xylem var choices=[a b c d etcetc];
Then I ask. What is choices.length;?
Greg Duncan
@GregatGit
Aug 24 2016 03:29
@tyl-er you can work with your js at https://repl.it - and console.log(res) and any other variable to see what you are getting
Chris Cullen
@123xylem
Aug 24 2016 03:29
@revisualize That was just a made up array for chat here.. the real one is in my code
Joseph
@revisualize
Aug 24 2016 03:29
@123xylem The answer is ERROR
Well, I didn't see that. So.
Chris Cullen
@123xylem
Aug 24 2016 03:30
my bad
Joseph
@revisualize
Aug 24 2016 03:30
I'm just looking at the code that you've posted.
BrianR
@brianrudloff
Aug 24 2016 03:33

How can I remove spaces and all non-alphanumeric characters from a string? And then make it all lower case?

var newstr = str.replace(( |*|_|#)g, "").toLowerCase;

Chris Cullen
@123xylem
Aug 24 2016 03:35
@revisualize thanks
CamperBot
@camperbot
Aug 24 2016 03:35
123xylem sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1711 | @revisualize |http://www.freecodecamp.com/revisualize
phanindra kumar mallempalli
@phani467
Aug 24 2016 03:46
hi
BrianR
@brianrudloff
Aug 24 2016 03:47

how can i remove spaces and all non-alphanumeric characters? then make it all lower case?

var newstr = str.replace(([^a-z]|[^0-9]), '').toLowerCase;

Boris
@boris-in-london
Aug 24 2016 03:56
@brianrudloff this book, http://eloquentjavascript.net/09_regexp.html has the best explanation of regular expressions imo. its a quick read and really informative. your answers in there.
Chris Cullen
@123xylem
Aug 24 2016 03:58
@revisualize do you get close to finding a way of me randomly selecting one of those HTML ids?
Joseph
@revisualize
Aug 24 2016 03:59
I didnt know I was supposed to.
Prasad Bhagat
@prasadb37
Aug 24 2016 03:59

function largestOfFour(arr) {

var largest=[];    

for(var i = 0; i < arr.length; i++){ 
    for (var j = 0; j < arr[i].length; j++) {
        if(arr[i][j] > largest){
            largest[i]= arr[i][j];

        }


    }

}

return largest;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
////// i want to return largest number in each array so the o/p should be a array containg[5,27,39,1001]

bt
Joseph
@revisualize
Aug 24 2016 03:59
Do your own stuff.
Prasad Bhagat
@prasadb37
Aug 24 2016 03:59
im getting
5,13only
Ari Winokur
@ariwinokur
Aug 24 2016 03:59
Still complete brainfreeze and freaking out about the Profile Lookup challenge!
Chad Powell
@cjpowellaz
Aug 24 2016 04:01
Working on Mutations challenge, this is what I have so far:

function mutation(arr) {
var newArray;

var arrayString = arr.toString();
var arrayLowerString= arrayString.toLowerCase();
var arrayLower = arrayLowerString.split(",");

if (arrayLower[0].indexOf(arrayLower1) === -1) {
return false;
} else if(arrayLower[0].indexOf(arrayLower1) > -1) {
return true;
}
}
mutation(["zyxwvutsrqponmlkjihgfedcba", "qrstu"]);

the ones not returning the correct value seem to need to be sorted first?
Chris Cullen
@123xylem
Aug 24 2016 04:02
@revisualize wow what a douche lol
@revisualize tell me ur looking into it then do ur own stuff
Chad Powell
@cjpowellaz
Aug 24 2016 04:02
like comparing: ["Mary", "Army"]
Chris Cullen
@123xylem
Aug 24 2016 04:03
@revisualize i used the word douche cos i think ur american but equally dick, moron, twat would apply
:)
Joseph
@revisualize
Aug 24 2016 04:03
@123xylem I was looking at the code you posted.
The code you posted in chat was not complete and full of errors.
Prasad Bhagat
@prasadb37
Aug 24 2016 04:05

Return Largest Numbers in Arrays
//my code
function largestOfFour(arr) {

var largest=[];    

for(var i = 0; i < arr.length; i++){ 
    for (var j = 0; j < arr[i].length; j++) {
        if(arr[i][j] > largest){
            largest[i]= arr[i][j];

        }


    }

}

return largest;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);

//exp o/p

[27,5,39,1001]

//i m getting
[5,13]

pls help in
Chris Cullen
@123xylem
Aug 24 2016 04:05
@revisualize no worries u can do ur own stuff aswell now... and yes im being pathetic :) but problem solving and rude people are a bad combination for me
Prasad Bhagat
@prasadb37
Aug 24 2016 04:05
i m stuck in this
swapnildaddikar
@swapnildaddikar
Aug 24 2016 04:05
there are ppl here who write some this on github on some lame record collection and think they know everything lmao
Boris
@boris-in-london
Aug 24 2016 04:05
@prasadb37 , i see an issue here if(arr[i][j] > largest){ largest[i]= arr[i][j]; largest is an empty array. why use > on empty array?
Joseph
@revisualize
Aug 24 2016 04:06
But, Thank you. I am a douche, dick, moron, twat and asshole for reading your shit code and not knowing that there was a larger code base that you did not even define. But, yeah... Thank you for inferring that I have ESP.
I will go back to being me.
swapnildaddikar
@swapnildaddikar
Aug 24 2016 04:06
gtfo
Boris
@boris-in-london
Aug 24 2016 04:06
lol should i get some popcorn?
Prasad Bhagat
@prasadb37
Aug 24 2016 04:07
i tried to put zero in that
Boris
@boris-in-london
Aug 24 2016 04:07
@revisualize take the high road on this one buddy.
Prasad Bhagat
@prasadb37
Aug 24 2016 04:07
still getting same ans
Joseph
@revisualize
Aug 24 2016 04:07
Just thanking the guy for pointing out all the thing that define me.
Because clearly he knows everything about me by thin slicing one moment from eternity.
Ari Winokur
@ariwinokur
Aug 24 2016 04:09
I feel so lost on the Profile Lookup challenge, but I don't want to walk away from it and deal with it later. This is very frustrating!
Boris
@boris-in-london
Aug 24 2016 04:09
lol yeah, i also noticed he's new here. he's not up to speed on the culture.
he was out of line
Prasad Bhagat
@prasadb37
Aug 24 2016 04:10
@boris-in-london
Boris
@boris-in-london
Aug 24 2016 04:10
@prasadb37 you tried to put zero in largest variable? then it will always be smaller and you will get the same answer
Prasad Bhagat
@prasadb37
Aug 24 2016 04:10
@boris-in-london ok
Suraj Kamath
@surajkamath4sk
Aug 24 2016 04:11
@matszym thanks ! :)
CamperBot
@camperbot
Aug 24 2016 04:11
surajkamath4sk sends brownie points to @matszym :sparkles: :thumbsup: :sparkles:
:cookie: 153 | @matszym |http://www.freecodecamp.com/matszym
swapnildaddikar
@swapnildaddikar
Aug 24 2016 04:12
anyone here knows a good site where i can get all basics and syntax related to JSON related functions
Suraj Kamath
@surajkamath4sk
Aug 24 2016 04:12
@matszym we should also have a server.js file rt?
Ari Winokur
@ariwinokur
Aug 24 2016 04:14
Help?
swapnildaddikar
@swapnildaddikar
Aug 24 2016 04:15
@ariwinokur its really easy ... if ur frustrated now get some rest do something else and come back to it later
:D
Ari Winokur
@ariwinokur
Aug 24 2016 04:22
@swapnildaddikar I get that impression. I just don't want to close up and come back tomorrow.
swapnildaddikar
@swapnildaddikar
Aug 24 2016 04:23
its okay dont go hard on urself its jst a code.... also i guarantee u will be able to do it just read through the previous lessons once again and next thing u know u have cracked it :D
Ari Winokur
@ariwinokur
Aug 24 2016 04:25
What frustrates me most is that I've been crushing most of the other lessons over the past couple days and now I'm just having a lot of trouble!
swapnildaddikar
@swapnildaddikar
Aug 24 2016 04:25
yes i know even i have been there
we all have
right now even im stuck on a part im not able to figure out
but its okay :D
if u want to do it right nw i would suggest go through the previous lessons once more ... get ur basics right and u will be able to solve it in no time
Michael Karpinski
@karpimpski
Aug 24 2016 04:26
can anybody help me with a progress bar? I'm not quite sure what I'm doing wrong here:
function move(business) {
    var elem = document.getElementById(business.id);
    var width = 1;
    var id = setInterval(frame, 10);
    function frame() {
        if (width >= 100) {
            clearInterval(id);
        } else {
            width++; 
            elem.style.background = 'linear-gradient(to left, green '+width+'%, white '+(100-width)+')';
        }
    }
}
Ari Winokur
@ariwinokur
Aug 24 2016 04:27
@swapnildaddikar would you have a recommendation on how far back to go in order to get a good summary of the code needed?
swapnildaddikar
@swapnildaddikar
Aug 24 2016 04:28
let me check
Ari Winokur
@ariwinokur
Aug 24 2016 04:28
Thanks!
swapnildaddikar
@swapnildaddikar
Aug 24 2016 04:30
from build javascript objects
section
Ari Winokur
@ariwinokur
Aug 24 2016 04:30
I will look at that. Thanks @swapnildaddikar !
CamperBot
@camperbot
Aug 24 2016 04:30
ariwinokur sends brownie points to @swapnildaddikar :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for swapnildaddikar
swapnildaddikar
@swapnildaddikar
Aug 24 2016 04:30
cool u will solve it in no time
Ari Winokur
@ariwinokur
Aug 24 2016 04:30
Thanks for the vote of confidence!
swapnildaddikar
@swapnildaddikar
Aug 24 2016 04:30
a hint
Ari Winokur
@ariwinokur
Aug 24 2016 04:31
a hint?
swapnildaddikar
@swapnildaddikar
Aug 24 2016 04:31
here if u see
its an array
so u have to access elements inside it as an array
like array[0] .. 1
and then check if that object has its property
all this is covered in the previous lessons
just read through the build javbascript objects
and u will crack it :D
Ari Winokur
@ariwinokur
Aug 24 2016 04:32
Thanks!
swapnildaddikar
@swapnildaddikar
Aug 24 2016 04:32
cool
Chad Powell
@cjpowellaz
Aug 24 2016 04:33
help Method
CamperBot
@camperbot
Aug 24 2016 04:33
no wiki entry for: method
Chad Powell
@cjpowellaz
Aug 24 2016 04:33
help Mutations
CamperBot
@camperbot
Aug 24 2016 04:33
no wiki entry for: mutations
comaeternal
@comaeternal
Aug 24 2016 04:43
Whats wrong with my code?

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"
}

           }   

  return;
  // Only change code above this line
}

// Change these values to test
golfScore(4, 5);
golfScore(4,4) should be par and golfscore(4,5) should be bogey
Ari Winokur
@ariwinokur
Aug 24 2016 04:45
You left out the Go Home part
Chad Powell
@cjpowellaz
Aug 24 2016 04:46
How can I use the indexOf method forward and backward to compare two objects in an array?
Boris
@boris-in-london
Aug 24 2016 04:46
@karpimpski i think it's because you're calling clearInerval(id) inside your setInterval(frame, 10); function.
Eliz
@elizso
Aug 24 2016 04:46
Screen Shot 2016-08-24 at 12.45.53 PM.png
Luis Felipe López G.
@luishendrix92
Aug 24 2016 04:46
@comaeternal The = sign is not the same as the strict or loose comparison operators
Michael Karpinski
@karpimpski
Aug 24 2016 04:47
@boris-in-london no, that's worked before with different work. this is a weird CSS issue. when I put in desired values manually with CSS I get undesired results
Eliz
@elizso
Aug 24 2016 04:47
Anyone know how to fix the problem?
Michael Karpinski
@karpimpski
Aug 24 2016 04:47
I'm working on fixing it now
Boris
@boris-in-london
Aug 24 2016 04:48
@karpimpski sorry ignore what i wrote. my mistake
Michael Karpinski
@karpimpski
Aug 24 2016 04:48
@boris-in-london it's no problem! I appreciate the help anyway :)
Chad Powell
@cjpowellaz
Aug 24 2016 04:49
How can I use the indexOf method forward and backward to compare two objects in an array?
Michael Karpinski
@karpimpski
Aug 24 2016 04:49
here's the solution @boris-in-london
function frame() {
        var secondWidth = 100 - width;
        if (width >= 100) {
            setInterval(function(){
                clearInterval(id);
            }, 100);
        } else {
            width++; 
            if(width < 50){
                elem.style.background = '-webkit-linear-gradient(right, #897D77, #897D77 '+(100-width)+'%, green 30%, green)';
            }
            else{
                elem.style.background = '-webkit-linear-gradient(left, green, green '+width+'%, #897D77 30%, #897D77)';
            }
        }
    }
Boris
@boris-in-london
Aug 24 2016 04:51
lol thanks @karpimpski, i would not have guessed that. so chrome compatibility issue?
CamperBot
@camperbot
Aug 24 2016 04:51
boris-in-london sends brownie points to @karpimpski :sparkles: :thumbsup: :sparkles:
:cookie: 384 | @karpimpski |http://www.freecodecamp.com/karpimpski
Michael Karpinski
@karpimpski
Aug 24 2016 04:52
@boris-in-london it's just a weird gradient issue. whenever I was under 50% I got this weird, mixed-in look. so I just made it so that no matter what the value was over 50%
Boris
@boris-in-london
Aug 24 2016 04:52
ah... ok.
Michael Karpinski
@karpimpski
Aug 24 2016 04:52
probably not the BEST solution, but I'm just trying to get the design done quick so I can get to the non-design part of it
Boris
@boris-in-london
Aug 24 2016 04:52
hey if it works! :+1:
Chad Powell
@cjpowellaz
Aug 24 2016 04:53
How can I use the indexOf method forward and backward to compare two objects in an array?
Pogg
@fogkio
Aug 24 2016 04:54
How can i Check out our brand new Open Data T-shirts in our shop.
Reverse a String
Reverse a String
in Algothrm Scripting?
arif hussain
@arifhussain0
Aug 24 2016 04:56
hello . can anyone give me idea about how to get started with validating US number exercise ?
Paulo Alexandre
@PauloFurtunatoAlexandre
Aug 24 2016 04:59
function abTest(a, b) {
  // Only change code below this line

  if (a || b < 0);
  return undefined;
} 

  // Only change code above this line

  return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
}

// Change values below to test your code
abTest(2,2);
abTest(-2,2);
abTest(2,-2);
the exercise is asking to exit the function immediately if a or b are less than 0
with the value of undefined
I believe it is related to closure this one...
the thing is, I don't know how to use the example given in this one...
arif hussain
@arifhussain0
Aug 24 2016 05:01
do a<0 || b<0 in if condition
Matt Reynolds
@mareynolds
Aug 24 2016 05:01

In Arguments Optional, one of the tests is to run a function

addTogether(2)([3]) //should return undefined.

However, the second part "(3)" causes problems whenever I run my code. I get this error:
TypeError: addTogether(...) is not a function.
How can you run a function with addTogether(X)(Y) ? Just having addTogether(X) makes sense, but the parentheses after that doesn't compute... Can anyone help explain that?

Paulo Alexandre
@PauloFurtunatoAlexandre
Aug 24 2016 05:02
@arifhussain0 it did not work :(
Pogg
@fogkio
Aug 24 2016 05:02

function reverseString(str) {
  var a = [str];
  return a.reverse();
}

reverseString("hello");
how can i reverse work with every single word?
:(
Joseph
@revisualize
Aug 24 2016 05:03
@fogkio You're not returning a string. you're returning an array.
Pogg
@fogkio
Aug 24 2016 05:03
but i return a string
Joseph
@revisualize
Aug 24 2016 05:03
@fogkio No it isn't.
It is returning an array.
Pogg
@fogkio
Aug 24 2016 05:03
i give str to array
arif hussain
@arifhussain0
Aug 24 2016 05:04
@gigaPaul what exactly is the error because this should work if either a or b is less than 0
Pogg
@fogkio
Aug 24 2016 05:04
then what can i do next
Joseph
@revisualize
Aug 24 2016 05:04
@fogkio Look, https://www.repl.it/CqyA
[] denotes an array.
arif hussain
@arifhussain0
Aug 24 2016 05:05
what is the outcome of ur code in current condition?
Paulo Alexandre
@PauloFurtunatoAlexandre
Aug 24 2016 05:05
@arifhussain0 I rolled down here... there are all these conditions to be accomplished
abTest(2,2) should return a number
abTest(2,2) should return 8
abTest(-2,2) should return undefined
abTest(2,-2) should return undefined
abTest(2,8) should return 18
abTest(3,3) should return 12
I am working on it...
mamun
@fsdmamun
Aug 24 2016 05:06

i want to get only "egg": what should I call---- function pl(val){
var result ="";
var lookup = {
"a":"adam",
"b":"beta",
"c":"cat",
"d":"data",
"e":["echo","egg"],

};

result = lookup[val];
return result;

}
pl (["e"][0]);

BrianR
@brianrudloff
Aug 24 2016 05:08

What does the "_" after the "W" mean in this expression...

var normalizedStr = str.replace(/[\W_]/g, '').toLowerCase();

Chris Cullen
@123xylem
Aug 24 2016 05:09
I have a prompt that starts program on doc ready, problem is it only runs one time... How can I keep it running? I tried calling its main function (ACT) inside itself but it doesnt work more than once...
$(document).ready(function(){
 var user=  prompt("Choose X or O","Make sure its Caps!");
if (user=="X") {
   userX=1 ; 
  $(".box").on('click', function act(){
  var id = $(this).attr('id');
  switch(id){ 
    case "a":
      choices.splice(0, 1);
answer.push("A");       break;
    case "b":
            choices.splice(1, 1);

answer.push("B");         break;
         case "c":
            choices.splice(2, 1);

answer.push("C");       break;   
   case "d":
            choices.splice(3, 1);

answer.push("D");       break;   
   case "e":
            choices.splice(4, 1);

answer.push("E");       break;    
   case "f":
            choices.splice(5, 1);

answer.push("F");       break;  
   case "g":
            choices.splice(6, 1);

answer.push("G");       break;    
   case "h":
            choices.splice(7, 1);

answer.push("H");       break;    
   case "i":
            choices.splice(8, 1);

answer.push("I");       break;

};   console.log(answer);   
 cpu(); act();
     }); 
}
Matt Reynolds
@mareynolds
Aug 24 2016 05:10
has anyone here completed the Arguments Optional algorithm challenge?
Michael Karpinski
@karpimpski
Aug 24 2016 05:11
@123xylem setInterval
Markus Kiili
@Masd925
Aug 24 2016 05:12
@mareynolds Yes.
Chad Powell
@cjpowellaz
Aug 24 2016 05:12
can anyone verify if my questions are getting posted!??!
Joseph
@revisualize
Aug 24 2016 05:13
@cjpowellaz I regret to inform you that no one can see your questions. Not even the one where you're asking if anyone can see your questions. No one has seen that either.
Markus Kiili
@Masd925
Aug 24 2016 05:13
@mareynolds addTogether(2) should return a function of one parameter and ([3]) calls that function on addTogether(2)([3]).
Chris Cullen
@123xylem
Aug 24 2016 05:13
@karpimpski what if the player is too slow though :)
Eliz
@elizso
Aug 24 2016 05:14
// Declare your variable here
var myGlobal=10;

function fun1(oopsGlobal) {
  // Assign 5 to oopsGlobal Here
  oopsGlobal=5;
}
// Only change code above this line
function fun2() {
  var output = "";
  if (typeof myGlobal != "undefined") {
    output += "myGlobal: " + myGlobal;
  }
  if (typeof oopsGlobal != "undefined") {
    output += " oopsGlobal: " + oopsGlobal;
  }
  console.log(output);
}
myGlobal should be defined
myGlobal should have a value of 10
myGlobal should be declared using the var keyword
oopsGlobal should have a value of 5
Do not declare oopsGlobal using the var keyword
Anyone can help?
Michael Karpinski
@karpimpski
Aug 24 2016 05:14
@123xylem every time the player clicks, run the function so that the computer chooses
Tracey Bushman
@tbushman
Aug 24 2016 05:14
@cjpowellaz verified. Just looking here... have you tried sort() ?
Chad Powell
@cjpowellaz
Aug 24 2016 05:14
someone answered!! Step 1
Chris Cullen
@123xylem
Aug 24 2016 05:14
@karpimpski yea thats what its meant to do... maybe I should take the function away from prompt?
Michael Karpinski
@karpimpski
Aug 24 2016 05:15
@123xylem I'm not exactly sure then. I'm sorry. like I said, I can look through your CodePen tomorrow to help more thoroughly if you remind me
Tracey Bushman
@tbushman
Aug 24 2016 05:16
sort(function(a,b){return a-b;} gets you ascending, sort(function(a,b){return b-a;} gives descending order
Chad Powell
@cjpowellaz
Aug 24 2016 05:16
I am working on Mutations challenged and following the wiki hints. what I have is this:

function mutation(arr) {
var newArray;

var arrayString = arr.toString();
var arrayLowerString = arrayString.toLowerCase();
var arrayLower = arrayLowerString.split("");

if (arrayLower.indexOf(0) === -1) {
return false;

} else if (arrayLower.indexOf() > -1) {
return true;
}
}
mutation(["zyxwvutsrqponmlkjihgfedcba", "qrstu"]);

the wiki hints say to make all lower case and split into an array of characters then use indexOf to compare
so far I can only get the "false" results to return
Matt Reynolds
@mareynolds
Aug 24 2016 05:17

@Masd925 but if that were the case, when I test

addTogether(2)([3]) //should return undefined.

I keep getting this returned:
TypeError: addTogether(...) is not a function.
It works fine if I run addTogether(2) by itself, or addTogether(2,3) though... what am I missing here?

Paulo Alexandre
@PauloFurtunatoAlexandre
Aug 24 2016 05:17
// Setup
function abTest(a, b) {
  // Only change code below this line

  if (a < 0 || b < 0);
    return undefined;
} else if (a == 2 && b == 2){
    return 8;
} else if (a == 2 && b == 8) {
    return 18;
} else (a == 3 && b == 3){
    return 12;
}

  // Only change code above this line

  return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
}

// Change values below to test your code
abTest(2,2);
abTest(-2,2);
abTest(2,-2);
abTest(2, 8);
abTest(3, 3);
Markus Kiili
@Masd925
Aug 24 2016 05:18
@cjpowellaz Don't cast arr to string. Just pick the strings into variables like var first = arr[0]; and lowercase them.
Chris Cullen
@123xylem
Aug 24 2016 05:18
@karpimpski cheers man
Paulo Alexandre
@PauloFurtunatoAlexandre
Aug 24 2016 05:18
does not evaluate for the exercise... only fulfill the abTest(-2,2) should return undefined
abTest(2,-2) should return undefined
Markus Kiili
@Masd925
Aug 24 2016 05:18
@mareynolds When one argument in passed to addTogether, it should return a function. Is your addTogether function doing that?
Paulo Alexandre
@PauloFurtunatoAlexandre
Aug 24 2016 05:18
the rest is not evaluating
Chad Powell
@cjpowellaz
Aug 24 2016 05:19
hmmm...ok. will try that. Thanks @Masd925
CamperBot
@camperbot
Aug 24 2016 05:19
cjpowellaz sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2349 | @masd925 |http://www.freecodecamp.com/masd925
Matt Reynolds
@mareynolds
Aug 24 2016 05:20

@Masd925 yes, if there is just one argument ( e.g. addTogether(2) ) then I've got

return sumTwoAnd();

then the function sumTwoAnd() right below that

Tracey Bushman
@tbushman
Aug 24 2016 05:21
your second instance of indexOf(..) is empty and ... you need a 'for' loop to iterate through the array ... @cjpowellaz
Markus Kiili
@Masd925
Aug 24 2016 05:21
@mareynolds That is returning the return value of a function call sumTwoAnd(). Instead, return sumTwoAnd; would return the function.
Chad Powell
@cjpowellaz
Aug 24 2016 05:22
oh....ok. Thanks @tbushman
CamperBot
@camperbot
Aug 24 2016 05:22
cjpowellaz sends brownie points to @tbushman :sparkles: :thumbsup: :sparkles:
:cookie: 112 | @tbushman |http://www.freecodecamp.com/tbushman
Matt Reynolds
@mareynolds
Aug 24 2016 05:22
oh that makes sense. Thanks @Masd925
CamperBot
@camperbot
Aug 24 2016 05:22
mareynolds sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2350 | @masd925 |http://www.freecodecamp.com/masd925
jovmassimiliano
@jovmassimiliano
Aug 24 2016 05:25
test
Kathy Dunning
@dunningkatherin
Aug 24 2016 05:37

JavaScript : Instructions
Assign the value 7 to variable a.

Assign the contents of a to variable b.

Do not change code above the line
a should have a value of 7
b should have a value of 7
a should be assigned to b with =
I thought it was this....
var a = 7;
var b = 7;
a === b;
How do I assign a to b with = ?
Coryphaeus
@cvdeveloper13
Aug 24 2016 05:38
a = b
ou, b = a)
sorry, b += a
or b = b + a;
Kathy Dunning
@dunningkatherin
Aug 24 2016 05:40
It's not letting me pass this part...
Ah, Got It!!
Paulo Alexandre
@PauloFurtunatoAlexandre
Aug 24 2016 05:42
@dunningkatherin you could assign b = a;
Kathy Dunning
@dunningkatherin
Aug 24 2016 05:42
var a = 7;
var b = a;
Paulo Alexandre
@PauloFurtunatoAlexandre
Aug 24 2016 05:42
good work!
Kathy Dunning
@dunningkatherin
Aug 24 2016 05:43
:-)
Joel Santos
@St3ps
Aug 24 2016 05:46
Hey guys, quick question: I have the following jquery and i've noticed that if i add a click event in the following way i can't seem to be able to access anything of the following div other than it's class attribute
/* this is a prototype function, ommited for simplicity */
selectMenu: function() {

$('.select-menu').html('<a href="#" role="button" data-value="X"><div class="col-md-6 btn-menu"><h1>Choose X</h1></div></a> /* this is just to place the html */

$('.btn-menu').click(function () {
console.log($(this).data('value')); /* returns undefined */
}

}
jovmassimiliano
@jovmassimiliano
Aug 24 2016 05:46
else if(prop==="tracks" && value!==""){
    if(collection[id][prop].hasOwnProperty("tracks")===true)
    {
      collection[id][prop].push(value);
    }
    else{
      collection[id].tracks=[value];
    }
hey guys i'm stuck in record challenge part, does anyone know how to push new tracks to existing tracks?
Markus Kiili
@Masd925
Aug 24 2016 05:47
@jovmassimiliano if(collection[id].hasOwnProperty("tracks"))
jovmassimiliano
@jovmassimiliano
Aug 24 2016 05:49
@Masd925 oh god, thanks man!
CamperBot
@camperbot
Aug 24 2016 05:49
jovmassimiliano sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2351 | @masd925 |http://www.freecodecamp.com/masd925
stonefmagiecurata
@stonefmagiecurata
Aug 24 2016 06:01
@St3ps data-value="X is an attribute of the a not the div with the class btn-menu
@St3ps try this: console.log($(this).parent().data('value'))
Chad Powell
@cjpowellaz
Aug 24 2016 06:13
working on Mutations challenge, following the hints in the wiki, I have lower cased and split into characters, how does the indexOf fit in next to compare?

function mutation(arr) {

var first = arr[0].toLowerCase().split("");
var second = arr1.toLowerCase().split("");

}
mutation(["HELLO", "hello"]);

gadzet
@gadzet
Aug 24 2016 06:16
Good morning guys, anyone good on algorithms here ?
need a hint :))
Markus Kiili
@Masd925
Aug 24 2016 06:16
@gadzet I can try.
this is the assigment with a work so far
sry for the comments they're in my own language
Markus Kiili
@Masd925
Aug 24 2016 06:17
@gadzet It is better if you copy-paste the code here formatted.
explain format
CamperBot
@camperbot
Aug 24 2016 06:17
no wiki entry for: format
gadzet
@gadzet
Aug 24 2016 06:17

``` function whatIsInAName(collection, source) {
// What's in a name?
var arr = [];
// Only change code below this line
var srcKeys = Object.keys(source);
console.log("*!") ;
for(var i = 0; i < collection.length;i++){
// jeigu pirmo array object keys yra tokie patys kaip antro objekto keys
if(collection[i][srcKeys] === source[srcKeys]){
// pushinam i arr ciela objekta kuris atitiko kriterijus
arr.push(collection[i]);
}

}

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

whatIsInAName([{ "a": 1, "b": 2 }, { "a": 1 }, { "a": 1, "b": 2, "c": 2 }], { "a": 1, "b": 2 });

```

test
test
Markus Kiili
@Masd925
Aug 24 2016 06:18
@gadzet You need to loop sources keys too and only push if the property values match for all the source keys.
gadzet
@gadzet
Aug 24 2016 06:18

`` function whatIsInAName(collection, source) {
// What's in a name?
var arr = [];
// Only change code below this line
var srcKeys = Object.keys(source);
console.log("*!") ;
for(var i = 0; i < collection.length;i++){
// jeigu pirmo array object keys yra tokie patys kaip antro objekto keys
if(collection[i][srcKeys] === source[srcKeys]){
// pushinam i arr ciela objekta kuris atitiko kriterijus
arr.push(collection[i]);
}

}

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

whatIsInAName([{ "a": 1, "b": 2 }, { "a": 1 }, { "a": 1, "b": 2, "c": 2 }], { "a": 1, "b": 2 });

``

damn it
what do you mean
i need two for loops
?
Markus Kiili
@Masd925
Aug 24 2016 06:19
Two loops (or iterations).
You could also use methods filter and every.
gadzet
@gadzet
Aug 24 2016 06:19
loop inside a loop ?
Markus Kiili
@Masd925
Aug 24 2016 06:19
@gadzet Yes.
gadzet
@gadzet
Aug 24 2016 06:20
do i have to use the filter method ?
is it mandatory or are there other ways
?
Markus Kiili
@Masd925
Aug 24 2016 06:21
@gadzet Your condition needs to hold for all the sources keys before you can push. You can use loops or methods. Methods make somewhat more compact and elegant code.
gadzet
@gadzet
Aug 24 2016 06:21
ok, thanks @Masd925
CamperBot
@camperbot
Aug 24 2016 06:21
gadzet sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2352 | @masd925 |http://www.freecodecamp.com/masd925
gadzet
@gadzet
Aug 24 2016 06:21
how long you're been coding
Markus Kiili
@Masd925
Aug 24 2016 06:22
@gadzet About 3 years and JS for about 1,5 years.
Chad Powell
@cjpowellaz
Aug 24 2016 06:23

function mutation(arr) {

var first = arr[0].toLowerCase().split("");
var second = arr1.toLowerCase().split("");

if (first.indexOf(second) === -1) {
return false;

} else if (first.indexOf(second) > -1) {
return true;
}

}
mutation(["HELLO", "hello"]);

gadzet
@gadzet
Aug 24 2016 06:23
i've completed the previous assignments like in 2-3 days, but intermediate feels real hard, feels like there was a gap inbetween those assignments ... :(
Chad Powell
@cjpowellaz
Aug 24 2016 06:23
anyone, anyone??
gadzet
@gadzet
Aug 24 2016 06:23
arr1.toLowerCase
mistake
here
should be arr1
ok its formated like this
Chad Powell
@cjpowellaz
Aug 24 2016 06:24
I have the [ ] around it
I am not sure why it turns it into a link like object
gadzet
@gadzet
Aug 24 2016 06:25
function mutation(arr) { var test = arr[1].toLowerCase(); var target = arr[0].toLowerCase(); for (i=0;i<test.length;i++) { if (target.indexOf(test[i]) < 0) return false; } return true; }
DJ
@qualitymanifest
Aug 24 2016 06:33
@cjpowellaz you can't use indexOf to check to see if an entire array's contents are in another array like that. you have to use it like array.indexOf(one single thing)
so a loop will be necessary
Iulian Crudu
@IulianCrudu
Aug 24 2016 06:34
Hello , can somebody help please. http://prntscr.com/c9onhk
what is wrong , i can not understand
gadzet
@gadzet
Aug 24 2016 06:34
@Masd925 is it possible to pass two parameters to filter function array and the source ?
Chad Powell
@cjpowellaz
Aug 24 2016 06:35
thanks @qualitymanifest @gadzet
CamperBot
@camperbot
Aug 24 2016 06:35
cjpowellaz sends brownie points to @qualitymanifest and @gadzet :sparkles: :thumbsup: :sparkles:
:cookie: 172 | @gadzet |http://www.freecodecamp.com/gadzet
:star2: 1372 | @qualitymanifest |http://www.freecodecamp.com/qualitymanifest
Pogg
@fogkio
Aug 24 2016 06:35
how can i complete this challenge?
Markus Kiili
@Masd925
Aug 24 2016 06:35
@gadzet You pass a function to filter that tells filter which elements to keep to the result array.
Pogg
@fogkio
Aug 24 2016 06:35
:worried:
@Masd925 hello
Markus Kiili
@Masd925
Aug 24 2016 06:36
@fogkio Hi.
Pogg
@fogkio
Aug 24 2016 06:36
@Masd925 can you help me :)
Reseve a string :D
Algothrm Scripting
Ajinkya
@AtiwadkarAjinkya
Aug 24 2016 06:36
Accessing Nested Objects
can anybody help me
Markus Kiili
@Masd925
Aug 24 2016 06:37
@fogkio For loop, recursion, array methods.. many choises.
Ajinkya
@AtiwadkarAjinkya
Aug 24 2016 06:37
myStorage.inside["glove box"].maps;
Pogg
@fogkio
Aug 24 2016 06:38

function reverseString(str) {
  var a = [str];
  return a.reverse;
}

reverseString("hello");
Markus Kiili
@Masd925
Aug 24 2016 06:38
@AtiwadkarAjinkya The .maps is not needed.
@fogkio Use .split(""); to turn the string into an array of characters.
Then reverse and .join("") back to string.
Ajinkya
@AtiwadkarAjinkya
Aug 24 2016 06:39
myStorage.inside["glove box"]; will this do @Masd925
gadzet
@gadzet
Aug 24 2016 06:39
@Masd925 but whatIsInAName function has two values, i will need the source in the filter function to use it as a critereria, and then i will call it with a collection array ?
Pogg
@fogkio
Aug 24 2016 06:40
@Masd925 Kayyy
Markus Kiili
@Masd925
Aug 24 2016 06:41
@gadzet If you use filter the structure should be like:
var keyList = Object.keys(source);
  arr = collection.filter(function(obj){
gadzet
@gadzet
Aug 24 2016 06:41
@Masd925 or should i declare the filter function inside the main function to keep the collection and the source ?
Markus Kiili
@Masd925
Aug 24 2016 06:41
and you use keyList and the object being iterated obj inside the filter callback. Return true from the callback for those objects obj that you like filter to keep.
1p2r3a
@1p2r3a
Aug 24 2016 06:42
hi to store large amount of data nearly (10 lakhs) which database we want to use
any one give idea
Eliz
@elizso
Aug 24 2016 06:42
Does anyone know how to finish Global Scope and Functions challenge
1p2r3a
@1p2r3a
Aug 24 2016 06:43
which database will useful
efficiently
Pogg
@fogkio
Aug 24 2016 06:44
@Masd925 why error always split not a funciton?
1p2r3a
@1p2r3a
Aug 24 2016 06:44
plz suggest mee
Eliz
@elizso
Aug 24 2016 06:44
Can anyone help me please?
Pogg
@fogkio
Aug 24 2016 06:44
shall i need to contructor?
Markus Kiili
@Masd925
Aug 24 2016 06:44
@fogkio You have some syntax error there. Post the code.
Ajinkya
@AtiwadkarAjinkya
Aug 24 2016 06:45
@Elizso ?
Pogg
@fogkio
Aug 24 2016 06:46
@Masd925 ```

function reverseString(str) {
  var a = [str];
  var array=[];
  array = a.split();
  array = array.reverse();
  return a;
}

reverseString("hello");
it just a my think
not good at all
MikeBison
@MikeBison
Aug 24 2016 06:46
hi there,anyone knows how to finish 'Factorialize a Number'?
Markus Kiili
@Masd925
Aug 24 2016 06:46
@fogkio Just var array=str.split("");
MikeBison
@MikeBison
Aug 24 2016 06:46

function factorialize(num) {
return num!;
}

factorialize(5);

Markus Kiili
@Masd925
Aug 24 2016 06:47
@fogkio You can chain the reversing and joining on that same line. And the returning too.
1p2r3a
@1p2r3a
Aug 24 2016 06:47
guys
Markus Kiili
@Masd925
Aug 24 2016 06:47
@MikeBison ! in not factorial in javascript. It is NOT operator.
Eliz
@elizso
Aug 24 2016 06:47
I dont know how to finish the global scope and functions challenge @AtiwadkarAjinkya
Ajinkya
@AtiwadkarAjinkya
Aug 24 2016 06:48
delare a var myGlobal @Elizso
MikeBison
@MikeBison
Aug 24 2016 06:48
wow,it is not a keyword?
@Masd925 right?
thank you! @Masd925
CamperBot
@camperbot
Aug 24 2016 06:49
mikebison sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2353 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Aug 24 2016 06:49
@MikeBison ! is an operator that flips a boolean value.
Eliz
@elizso
Aug 24 2016 06:49
No there is a variable call oops global and i have no idea how to fix it @AtiwadkarAjinkya
1p2r3a
@1p2r3a
Aug 24 2016 06:49
suggeest me a database to store large amount of data
Pogg
@fogkio
Aug 24 2016 06:49
a same line?
@Masd925 like this?
var array=str.split.reverse();
?
=D
Ajinkya
@AtiwadkarAjinkya
Aug 24 2016 06:50
delare oopsGlobal=5 in fun1() @Elizso
MikeBison
@MikeBison
Aug 24 2016 06:50
@fogkio str.split("").reverse().join("");
Markus Kiili
@Masd925
Aug 24 2016 06:50
@fogkio return str.split("").reverse().join(""); would do.
Ajinkya
@AtiwadkarAjinkya
Aug 24 2016 06:50
dont use var @Elizso
John Carlo
@JohnCarlo
Aug 24 2016 06:51
guys im starting to study javascript hope you guys will help me to understand it if im doing it wrong :(
Eliz
@elizso
Aug 24 2016 06:54
ok thanks @AtiwadkarAjinkya
CamperBot
@camperbot
Aug 24 2016 06:54
elizso sends brownie points to @atiwadkarajinkya :sparkles: :thumbsup: :sparkles:
:cookie: 246 | @atiwadkarajinkya |http://www.freecodecamp.com/atiwadkarajinkya
零度
@qdxt
Aug 24 2016 06:55
252 who do this?
Markus Kiili
@Masd925
Aug 24 2016 06:56
@qdxt There are no challenge numbers, only names.
Ajinkya
@AtiwadkarAjinkya
Aug 24 2016 06:57
@Masd925 Thanks
CamperBot
@camperbot
Aug 24 2016 06:57
atiwadkarajinkya sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2354 | @masd925 |http://www.freecodecamp.com/masd925
零度
@qdxt
Aug 24 2016 06:58
Check for Palindromes who do this?
@Masd925 Check for Palindromes
1p2r3a
@1p2r3a
Aug 24 2016 06:59

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

function myObj(checkProp) {
myObj.hasOwnProperty("pony");

// Your Code Here

return "Change Me!";
}

// Test your code by modifying these values
checkObj("gift");
find the error in this challenge

Markus Kiili
@Masd925
Aug 24 2016 07:00
@qdxt You need to first remove all non-alphanumeric characters from the string.
@1p2r3a Use the function parameter checkProp as the property key to test.
@1p2r3a It holds the passed property key when the function call is made.
1p2r3a
@1p2r3a
Aug 24 2016 07:01
cant understand
零度
@qdxt
Aug 24 2016 07:03
@Masd925 谢谢。
thanks
Markus Kiili
@Masd925
Aug 24 2016 07:04
@1p2r3a When a function call is made checkObj("gift");, the function parameter checkProp will have a value "gift". On some different call the value will be different. Your function must work with any passed value, so you have to use the function parameter checkProp (function input) when you produce the function return value (output).
So instead of "pony" use checkProp.
Pogg
@fogkio
Aug 24 2016 07:05
@Masd925 thanks
CamperBot
@camperbot
Aug 24 2016 07:05
fogkio sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2355 | @masd925 |http://www.freecodecamp.com/masd925
1p2r3a
@1p2r3a
Aug 24 2016 07:05
oh ok

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

function myObj(checkProp
) {
myObj.hasOwnProperty("checkProp");

// Your Code Here

return "Change Me!";
}

// Test your co

like this ah
r2d2
@UsamaHameed
Aug 24 2016 07:10
@1p2r3a you don't need those quotes
myObj.hasOwnProperty("checkProp"); will check for a string "checkProp"
Not the var checkProp
1p2r3a
@1p2r3a
Aug 24 2016 07:17
ok
Sreenivasa .B
@Sree-001
Aug 24 2016 07:18
Challenge Name : Seek and Destroy
I have written the following code

function destroyer(arr) {
// Remove all the values

var newarr=arr.filter(function(n){
return (n!==arguments1 && n!==arguments[2]);

});
return newarr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);

Markus Kiili
@Masd925
Aug 24 2016 07:19
@Sree-001 The filter callback function has its own arguments object.
@Sree-001 You also need to loop the arguments, because the number of arguments can vary.
Sreenivasa .B
@Sree-001
Aug 24 2016 07:20
ok then how to access aguements of the destroyer function
Markus Kiili
@Masd925
Aug 24 2016 07:20
@Sree-001 You can store destroyers arguments on a variable or pass arguments into the callback as value of this using filter syntax arr.filter(callback[, thisArg])
Sreenivasa .B
@Sree-001
Aug 24 2016 07:21
I'll try
its not working
1p2r3a
@1p2r3a
Aug 24 2016 07:26

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

function myObj(checkProp) {
myObj.hasOwnProperty("gift");
myObj.hasOwnProperty("pet");
myObj.hasOwnPoperty("bed");

// Your Code Here

return "Change Me!";
}

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

whether is it ok
hi @Masd925 one help do u know about the database
1p2r3a
@1p2r3a
Aug 24 2016 07:37
can anyone find the error for this
kennyq94
@kennyq94
Aug 24 2016 07:37
hey guys when i press switch units it turns into a bunch of data how do i get it to turn into text or html its suppose to show the temperature and F symbol as a test...pls help
https://codepen.io/kennyqsoftware/pen/yJXwyb
Markus Kiili
@Masd925
Aug 24 2016 07:44
@1p2r3a the database?
@1p2r3a Only use checkProp as the property key to test. Not "gift", "pet", or "bed". checkProp will hold the passed property key whatever it is.
1p2r3a
@1p2r3a
Aug 24 2016 07:46
ya database
Markus Kiili
@Masd925
Aug 24 2016 07:46
@1p2r3a What was your question about databases?
1p2r3a
@1p2r3a
Aug 24 2016 07:47
i want to store nearly 10 lakhs data which database will be efficient
Markus Kiili
@Masd925
Aug 24 2016 07:50
@1p2r3a All commonly used databases are meant to handle large amounts of data.
1p2r3a
@1p2r3a
Aug 24 2016 07:51
can you tell the efficient one
Alexander Domikov
@AlexanderDom
Aug 24 2016 07:52
Good morning !
1p2r3a
@1p2r3a
Aug 24 2016 07:52

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

function myObj(checkProp) {
myObj.hasOwnProperty("pony");
myObj.hasOwnProperty("Kitten");
myObj.hasOwnPoperty("sleigh");

// Your Code Here

return "Change Me!";
}

// Test your code by modifying these values
checkObj("gift");
can u change the code

i stuck in this
anyone help me to rearrange the code
Lenuta
@ionutlenuta
Aug 24 2016 07:56
instead of "pony", "Kitten"and"sleigh" you should use checkProp @1p2r3a
DarkManeiac
@DarkManeiac
Aug 24 2016 07:57
yea
myObj[checkProp]
like this
@ionutlenuta , from?
@1p2r3a , hey! are u still on?
Lenuta
@ionutlenuta
Aug 24 2016 07:59
Bistrita :smile:
DarkManeiac
@DarkManeiac
Aug 24 2016 07:59
fain
:)
Pogg
@fogkio
Aug 24 2016 08:01
Hiiii
DarkManeiac
@DarkManeiac
Aug 24 2016 08:01
hello
Pogg
@fogkio
Aug 24 2016 08:01
i have a question
In express regular
Markus Kiili
@Masd925
Aug 24 2016 08:02
@1p2r3a Choosing the database might have more to do with the type of data you are storing and how you would like to use it. All commonly used databases are efficient because that is one main goal of using a database. Different types of databases are based on different logic. Relational databases are based on relational theory (database tables hold true propositions and queries derive new true propositions) and some databases just store stuff as JSON etc.
Pogg
@fogkio
Aug 24 2016 08:02
how can i make it can find more than 1 sympols
Example
(eye) ~-> (e y_e)
i used /\s/gi
but cant add more symbol
:(
DarkManeiac
@DarkManeiac
Aug 24 2016 08:04
i forget...
i used simbols but i forgot
Pogg
@fogkio
Aug 24 2016 08:05

function palindrome(str) {
  var a = [str];
  var sympols = "/\s/gi";
  var result = str.replace(" ","");
  return result;
}
palindrome("e y_e");
Markus Kiili
@Masd925
Aug 24 2016 08:07
@fogkio Remove this line: var a = [str];
DarkManeiac
@DarkManeiac
Aug 24 2016 08:08
i need some help at the "Manipulating complex objects"
Ramesh syangtan
@rameshsyn
Aug 24 2016 08:08
@DarkManeiac :D
DarkManeiac
@DarkManeiac
Aug 24 2016 08:08
var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}
// Add record here
];
this is the code
Ramesh syangtan
@rameshsyn
Aug 24 2016 08:09
var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}
// Add record here
];
DarkManeiac
@DarkManeiac
Aug 24 2016 08:09
how are u doing that?
to look like that
:)
Ramesh syangtan
@rameshsyn
Aug 24 2016 08:09
wiki format
CamperBot
@camperbot
Aug 24 2016 08:09
no wiki entry for: format
DarkManeiac
@DarkManeiac
Aug 24 2016 08:10
ok, but help me at that pls :)
var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}
// Add record here
];
Ramesh syangtan
@rameshsyn
Aug 24 2016 08:10
just type three backstick and press shift + enter
ok what is the problem ?
DarkManeiac
@DarkManeiac
Aug 24 2016 08:10
\\
var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}
// Add record here
];
i must add on more album
or record
i must add a new album to the myMusic array.
Ramesh syangtan
@rameshsyn
Aug 24 2016 08:12
var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
},
 {
  "artist": "Justin Bieber",
  "title": "Sorry",
  "year": 2015,
  "format" : [
    "CS",
    "LP"
]
}
];
Kimon Haars
@Kimon-Haars
Aug 24 2016 08:13

Hi all,
the following function is supposed to output "pony" but it doesn't. I can't find out why. Does anyone have a hint?

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

function checkObj(checkProp) {
// Your Code Here

if (myObj.hasOwnProperty(checkProp)) {

return myObj.checkProp;
} else {
return "Not Found";
}
}

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

DarkManeiac
@DarkManeiac
Aug 24 2016 08:13

var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}
{
"artist": "Justin Bieber",
"title": "Purpose",
"release_year": 2015,
"formats": [
"QP",
"1U",
"OP" ],
"gold": true

}
];
like this it doesnt work'

i did it!!! thanks @rameshsyn !!!!C :)
CamperBot
@camperbot
Aug 24 2016 08:15
darkmaneiac sends brownie points to @rameshsyn :sparkles: :thumbsup: :sparkles:
:cookie: 783 | @rameshsyn |http://www.freecodecamp.com/rameshsyn
Ramesh syangtan
@rameshsyn
Aug 24 2016 08:16
:D
Pogg
@fogkio
Aug 24 2016 08:16
@Masd925 :( where are y :D
Manoj
@Manoj-Fernando
Aug 24 2016 08:16
had anyone finished counting card challlenge?
Markus Kiili
@Masd925
Aug 24 2016 08:17
@fogkio I have to work once in a while ;)
@Manoj-Fernando Yes.
Pogg
@fogkio
Aug 24 2016 08:18
@Manoj-Fernando too
done
Manoj
@Manoj-Fernando
Aug 24 2016 08:19
@Masd925 @fogkio

var count = 0;

function cc(card) {
// Only change code below this line
if(card===2||3||4||5||6){
count++;
}

if(card===7||8||9){

}

if(card==10||'J'||'Q'||'K'||'A'){
count--;
}
if (count>0){
var str=count+" Bet";
return str;
}
else if(count<=0){
var str1=count+" Hold";
return str1;
}
return "Change Me";
// Only change code above this line
}

where did i go wrong?
Markus Kiili
@Masd925
Aug 24 2016 08:20
@Manoj-Fernando This doesn't do what you think: if(card==10||'J'||'Q'||'K'||'A')
r2d2
@UsamaHameed
Aug 24 2016 08:20
Can anyone recommend some framework to build UI in advanced front end projects?
Markus Kiili
@Masd925
Aug 24 2016 08:20
It should be if (card===10 || card==="J" ||...
Jorge Martins
@jmartins00
Aug 24 2016 08:20
guys what´s wrong with this if?
if (val <= 50 && >= 25) {
return "yes";
}
Pogg
@fogkio
Aug 24 2016 08:20
why y dont use switch case?
@Manoj-Fernando
Ramesh syangtan
@rameshsyn
Aug 24 2016 08:20
@Kimon-Haars small mistake :D in object you need to call variable in bracket notation : myObj[checkProp]
// Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};
function checkObj(checkProp) {
// Your Code Here
if (myObj.hasOwnProperty(checkProp)) {
return myObj[checkProp];
} else {
return "Not Found";
}
}
// Test your code by modifying these values
checkObj("gift");
Manoj
@Manoj-Fernando
Aug 24 2016 08:21
@Masd925 ok ill try
Kimon Haars
@Kimon-Haars
Aug 24 2016 08:22
@rameshyn thanks! That solved it. :- ))
CamperBot
@camperbot
Aug 24 2016 08:22
kimon-haars sends brownie points to @rameshyn :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for rameshyn
Jorge Martins
@jmartins00
Aug 24 2016 08:22

if (val <= 50 && >= 25) {
return "yes";
}

what´s wrong with the if guys?

Kimon Haars
@Kimon-Haars
Aug 24 2016 08:22
@rameshsyn thanks! That solved it. :- ))
CamperBot
@camperbot
Aug 24 2016 08:22
kimon-haars sends brownie points to @rameshsyn :sparkles: :thumbsup: :sparkles:
Ramesh syangtan
@rameshsyn
Aug 24 2016 08:22
@jmartins00 you didn't set val for second condition
if (val <= 50 && val >= 25) {
return "yes";
}
CamperBot
@camperbot
Aug 24 2016 08:22
:cookie: 784 | @rameshsyn |http://www.freecodecamp.com/rameshsyn
gadzet
@gadzet
Aug 24 2016 08:22
f (val <= 50 && val >= 25)
Manoj
@Manoj-Fernando
Aug 24 2016 08:22
@Masd925 it worked out!!
gadzet
@gadzet
Aug 24 2016 08:22
u forgot the val
Jorge Martins
@jmartins00
Aug 24 2016 08:23
@gadzet ohh got it ahah thanks :D
CamperBot
@camperbot
Aug 24 2016 08:23
jmartins00 sends brownie points to @gadzet :sparkles: :thumbsup: :sparkles:
:cookie: 174 | @gadzet |http://www.freecodecamp.com/gadzet
Ramesh syangtan
@rameshsyn
Aug 24 2016 08:23
@Kimon-Haars :D
Pogg
@fogkio
Aug 24 2016 08:24
my solve :(
Manoj
@Manoj-Fernando
Aug 24 2016 08:24
@Masd925 Thank you!
CamperBot
@camperbot
Aug 24 2016 08:24
manoj-fernando sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2356 | @masd925 |http://www.freecodecamp.com/masd925
Pogg
@fogkio
Aug 24 2016 08:26
had someone finished challenge Palinddromes?
Ramesh syangtan
@rameshsyn
Aug 24 2016 08:26
@fogkio yes :D
stuck ??
Pogg
@fogkio
Aug 24 2016 08:26
can y help me :D
yeah
Ramesh syangtan
@rameshsyn
Aug 24 2016 08:26
what's the problem ? :D
Pogg
@fogkio
Aug 24 2016 08:27
are you use expression regular
to ignore symbol?

function palindrome(str) {
  var result = str.replace("/ /gi","");
  return result;
}
palindrome("e y_e");
my code now
but a symbol "_" i cant ignore that
Ramesh syangtan
@rameshsyn
Aug 24 2016 08:28
here it is str.replace(/[.,-\/#!$%\^&\*;:{}=\-_~()]/g,'');
Pogg
@fogkio
Aug 24 2016 08:28
can you explain?
Ramesh syangtan
@rameshsyn
Aug 24 2016 08:28
yes
above regex searches symbols and replace
DarkManeiac
@DarkManeiac
Aug 24 2016 08:30
guys, i think i have a bug </