Question

What's wrong with the following code? myCar['make'] = 'Ford'; myCar.model = 'Mustang'; myCar['year'] = 1969; alert(myCar.year);...

What's wrong with the following code?

myCar['make'] = 'Ford';

myCar.model = 'Mustang';

myCar['year'] = 1969;

alert(myCar.year);

Properties have to be accessed using brackets, not dot notation

Properties have to be accessed using dot notation, not brackets

It's missing var myCar = new Object();

Properties can be accessed using brackets or dot notation, but you can't mix the two

0 0
Add a comment Improve this question Transcribed image text
Answer #1

It's missing var myCar = new Object();

you need to create object for it. in order to access it .

Add a comment
Know the answer?
Add Answer to:
What's wrong with the following code? myCar['make'] = 'Ford'; myCar.model = 'Mustang'; myCar['year'] = 1969; alert(myCar.year);...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Codes: (car.h ; car.cpp ; carDemo.cpp) /* ----------------------- Car ----------------------- - make: string - year :...

    Codes: (car.h ; car.cpp ; carDemo.cpp) /* ----------------------- Car ----------------------- - make: string - year : int ----------------------- + Car() + setMake(m: string) : void + getMake() : string + setYear(y: int) : void + getYear() : int ---------------------- */ #ifndef CAR_H #define CAR_H #include <iostream> using namespace std; class Car { private: string make; int year; public: Car(); Car(string); Car(int); Car(string, int); void setMake (string); string getMake() {return make;} void setYear (int); int getYear() {return year;} }; #endif #include...

  • We are to make a program about a car dealership using arrays. I got the code...

    We are to make a program about a car dealership using arrays. I got the code to display all cars in a list, so I'm good with that. What I'm stuck at is how to make it so when a user inputs s for search, it allows them to search the vehicle. Here is what I have so far     public class Car {         String color;         String model;         String year;         String company;         String plate;       ...

  • Please code in C++. link to continue the code is this below or you can make...

    Please code in C++. link to continue the code is this below or you can make your own code if you wish(fix any mistakes if you think there are any in it): cpp.sh/3qcekv 3. Submit a header file (project3.h), a definition file (project3.cpp), a main file (main.cpp), and a makefile to compile them together. Make sure to run the command make and produce an application file and include it with your submission. For this project, you are required to create...

  • Can anyone identify which OO Design Patterns are being used in the following code?: package mis;...

    Can anyone identify which OO Design Patterns are being used in the following code?: package mis; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; import java.util.Scanner; class helpDeskGuidline{    private void setGuideLine(){           }    public void rateService(){           } } public class HelpDeskService extends helpDeskGuidline{ //HelpDeskService class extends helpDeskGuidline this    //called inheritance    private static int ticketId=1;    Ticket ticket; // HelpDeskService class using ticket class object. this is has-A relationship (aggregation)          ArrayList<Ticket> allTicket=new ArrayList<>();    HashMap<Ticket,Person> ticketAllocation=new HashMap<>();    HashMap<Person,Integer> assignee=new HashMap<>();    HelpDeskService(){        Person...

  • Code is in C# Your instructor would like to thank to Marty Stepp and Hélène Martin...

    Code is in C# Your instructor would like to thank to Marty Stepp and Hélène Martin at the University of Washington, Seattle, who originally wrote this assignment (for their CSE 142, in Java) This program focuses on classes and objects. Turn in two files named Birthday.cs and Date.cs. You will also need the support file Date.dll; it is contained in the starter project for this assignment. The assignment has two parts: a client program that uses Date objects, and a...

  • This lab will use 2D arrays, recursive algorithms, and logical thinking. The following grid of hashes(#)...

    This lab will use 2D arrays, recursive algorithms, and logical thinking. The following grid of hashes(#) and dots(.) is a 2D array representation of a maze # # # # # # # # # # # # # . . . # . . . . . . # . . # . # . # # # # . # # # # . # . . . . # . # # . . . . #...

  • What's Next? Will sharing replace owning? In much of the United States and Europe customers have...

    What's Next? Will sharing replace owning? In much of the United States and Europe customers have long viewed car ownership as a necessity. That is starting to change with evolving needs, attitudes, and life styles. Whether seeking a simpler life, a desire to save the planet, or just plain economics, many consumers are be- coming more comfortable with car sharing There is an economic case for turning in the keys Monthly payments, insurance, parking, gas, depreciation, and maintenance add up...

  • Can you please help me with creating this Java Code using the following pseudocode? Make Change C...

    Can you please help me with creating this Java Code using the following pseudocode? Make Change Calculator (100 points + 5 ex.cr.)                                                                                                                                  2019 In this program (closely related to the change calculator done as the prior assignment) you will make “change for a dollar” using the most efficient set of coins possible. In Part A you will give the fewest quarters, dimes, nickels, and pennies possible (i.e., without regard to any ‘limits’ on coin counts), but in Part B you...

  • Hi. Could you help me with the code below? I need to validate the code below, using expressions that can carry out the actions or that make appropriate changes to the program’s state, using conditiona...

    Hi. Could you help me with the code below? I need to validate the code below, using expressions that can carry out the actions or that make appropriate changes to the program’s state, using conditional and iterative control structures that repeat actions as needed. The unit measurement is missing from the final output and I need it to offer options to lbs, oz, grams, tbsp, tsp, qt, pt, and gal. & fl. oz. Can this be added? The final output...

  • please make a pretty JAVA GUI for this code this is RED BLACK TREE and i...

    please make a pretty JAVA GUI for this code this is RED BLACK TREE and i Finished code already jus need a JAVA GUI for this code ... if poosible make it pretty to look thanks and please make own GUI code base on my code thanks ex: (GUI only have to show RBTree) ---------------------------------------- RBTree.java import java.util.Stack; public class RBTree{    private Node current;    private Node parent;    private Node grandparent;    private Node header;    private Node...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT