@fmccroy it's kinda like in the first case you are creating just one array object, and storing the reference to that object in the test variable, then you create another reference to the same object. And since that object has one fixed location in memory, those 2 references are the same locations..

in the second case, you have 2 distinct objects at 2 different locations, so comparing their addresses returns false

is this something that can be done? I have an html page and I would like to execute the code entered by the user on a textarea. The code is javascript. in my page I would like to get the textarea and send it to the console, but I haven't figure out a way to do it. any help appreciated <script> function jstest() { var text = document.getElementById("textArea").value; console.log(text); } </script> </head> <body> <h2>Enter your code here!</h2> <form > <textarea rows="4" cols="50" id="textArea"></textarea><br> <input type="submit" value="Submit" onclick="jstest()"></form>

@alexandrupintilei It looks like you are trying to convert a whole string to character codes, and back into a string. You need to break the string into individual characters first, and then shift them 13 units, and convert back to characters again

can anyone solve this proplem !!Write an implementation for a function 'callAfter' that enables any function to be called after some specified duration with certain parameters, with the following mentioned syntax:Example: Lets say you have a function called 'sum' like so:function sum(a, b) {
console.log('Sum is: ', a + b);
}Now you should be able to execute:sum.callAfter(5000, 8, 9);

u wrote that above.. @pahosler

@moigithub your answer looks incorrect, and it doesn't delay for the time entered, the method call is supposed to be callAfter.sum(5000,8,9)notsum.callAfter(5000,8,9)

if u console.log the values passed u will see delay is 5000, and arguments is [5000, 8, 9]soo setTimeout function gets the correct delay value, and sum gets called with 8 and 9

@fdemaa - thiss is a very basic example of an object and methods (and properties). The idea is that you only "expose" the variables through methods so that you have full control over what values are set in the properties at any time. If anyone using your class in their code had free access to the variables, they could put values in there that could cause your object to not behave as it is supposed to. As I said, this simple example only shows that you cannot directly access the properties without using the methods.

@BrianCodes33 - this looks like a compilation error or syntax error in the user.component.ts file. Is that your own file? Check line 16, column 5 to see if it looks like it should have a comma?

This code passed, but I had to use code I found on w3Schools, which is the array2.sort(function(a,b) {
return b-a;
});

What I'm having trouble with us the a and b that are in function in the sort method. Obviously it's taking each element that is stored in array2 and comparing them and sorting them in descending order, but not sure how each element becomes a or b.

Also, I'm curious if anyone else could think of a better way to complete this instead of what I have above?

@NBTALOS - if you want to post it, we can have a look and see if you have anything that looks strange. I have seen cases where people have implemented code that strictly is written to pass the tests without applying the concept that is being taught - for example, instead of testing an object for a property and returning a value, there is a direct test of the incoming property name, and then returning the value that is expected in the test. As I said, any change in the test data would make the code break.

@kevinwr - another really neat and useful learning tool is http://pythontutor.com/javascript.html. You can plug your code in there and it will run it step by step, giving you visual indications of changing variables and data, how accesses are being made, etc. Once you get used to how it works, it is really great!

@decaren I applied that to my string, but it capitalizes each and every word in the string. I only need the first word. They also provide a tip to use split(). Not sure if that's the right way to go about it.

@Manish-Giri yeah, every first letter. I've been racking my brain trying to solve it. I did try splitting it to an array, and using bracket notation to get the first latter of each element, but that was throwing errors all over.

@coymeetsworld i was playing around with modules and using the ES 6 built-in method, on importing my module I had to use the require function which will take a string (the file path), I can't be replacing backslash \ all the time with / manually, so created a function, discussed with @Manish-Giri on the challenge till it just got solved

@Manish-Giri no clue? All I know is that I took the string, that was passed through to a function, then took that variable (str) and applied the .split() method to put each word into an array. I'm not sure if each element is a string now, or what.

@Evan171 check the values and increment or decrement count based on that, then you use a conditional statement to check if count is positive ( > 0) or negative then you return count + string (" Hold or Bet")

@kevinwr strings are immutable in JS you can't change the part of them directly you need to remake a new string and then you need to store your new one, either in pervious array or make a new one. there are some builtin methods that can do that for you.

It's so confusing because I don't know when to use one thing over something else. I also don't seem to know how loops, methods, functions, or anything else works. It's like everything I've done thus far has taught me nothing.

@NikolasP98 if you are using parameter to look for the property then you need to use [] bracket notation.

@NikolasP98 because contacts[i].prop will becomes contacts[i]."some value" and that will throw an exception, so to avoid it we use [] brackets, that accepts strings.. dot operator will only good where you have direct access to the object.

how can I make this if statement work for all contacts, and not just 0?´´´function lookUpProfile(firstName, prop){// Only change code below this lineif (firstName == contacts[0].firstName && contacts[0].hasOwnProperty(prop)){ return contacts[0][prop];}// Only change code above this line}´´´

Hello, need help. I am on Roman Numeral Converter. Below is my code. It is working but my method is not right. Look at console.log statements. I incremented x to make it number. It does that without actually adding 1. But want to know what is the better way.

Hi I'm having trouble with the 'Truncate a string' challenge in Basic Algorithm scripting. I must be missing something because I don't understand this error: 'truncateString("A-tisket a-tasket A green and yellow basket", "A-tisket a-tasket A green and yellow basket".length) should return "A-tisket a-tasket A green and yellow basket"'. Why doesn't this string need a '...' ending?

@jenniredfield Unless I'm overlooking something the problem is probably in their testing script. The first .length test should return "A-tisket a-tasket A green and yellow bas..." and the second "A-tisket a-tasket A green and yellow baske..."

@jenniredfield actually I just hacked it to make it pass by adding following.