Javascript
Provide code to create a custom object named pokerCard containing the suit property with a value of "Spades" and a rank property with a value of "King".
Solution:
We can create a custom object in following two ways:
1. Creating it as an object literal:
A custom object can be created by an object literal by storing the properties of the object within a comma-separated list of name:value pairs enclosed within a set of curly braces.
The general syntax of the object literal is
var objName = { name1: value1, name2: value2, ... };
where objName is the name of the object, name1, name2, and so on are the names associated with that object, and value1, value2, and so on are the values assigned to those names.
Code to create a custom object named pokerCard containing the suit property with a value of "Spades" and a rank property with a value of "King":
var card1 = { title: "pokerCard", suit: "Spades", rank: King};
2. Using an object constructor:
To create such object classes, you apply a function known as an object constructor or a constructor that defines the properties and methods associated with the object type. A specific object that is based on an object class is known as an object instance or instance. Creating an object instance based on an object class is known as instantiating an object.
Code to create a custom object named pokerCard containing the suit property with a value of "Spades" and a rank property with a value of "King":
The constructor function for an object class of poker cards might appear as follows:
function pokerCard(cardSuit, cardRank) { this.suit = cardSuit; this.rank = cardRank; this.rankValue = null; this.showCard() function() { return "Your card is a " + this.rank + " of " + this.suit; } }
Once the constructor function for the object class is defined, instances of the object are created with the command
var objInstance = new objClass(parameters);
where objInstance is a specific instance of the object, objClass is the object class as defined by the constructor function, and parameters are the values of any parameters included in the constructor function. Thus, the following code creates two instances of the class of pokerCard objects, one for the king of hearts and the other for the seven of spades:
var card1 = new pokerCard("Spades", "King"); card1.rankValue = 13;
Please give thumbsup, if you like it. Thanks.
Javascript Provide code to create a custom object named pokerCard containing the suit property with a...
Javascript Provide the code to add the custom dropRank() method to the pokerCard object that changes the value of the rank property to "Queen". (Hint: Create the dropRank() function and use the this keyword to reference the current object.)
code 3 different ways to insert a property-value pairing into a javascript object where the object name is Seneca, the property name is coursecode and the value is WEB322
create a javascript function named bbqFood that takes in an object and returns an array. The input object will have strings naming party foods as the key and the numbers of people that each key will feed as its values. return an array containing all of the keys whose values are greater than 10, menaing it will feed more than 10 people. example bbqfood(['taco':15, 'hamburger':6,'pasta':42,'fruit':23}) must return ['taco','pasta','fruit']
1. Provide code to create a selection list named orderDay containing the values and option text SAT and SUN placed in the Weekend option group, and the option text MON, TUE, WED, THU, and FRI placed in the Weekday option group. 2. Provide code to create two radio buttons for the compType field with the values PC and Mac. Make PC the default value. 3. Kelsey has written the following code to create a data field for users to select...
Javascript Object question: Write a function named "indexed_kvs" that doesn't take any parameters and returns a new key-value store containing the integers from 0 to 30 as values each stored at a key which is a string containing the digits of the integer. For example the key-value "0":0 will be in your returned key-value store (include both 0 and 30 in your list)
IN JAVA - COMMENT CODE WELL Write a class named Card which will represent a card from a deck of cards. A card has a suit and a face value. Suits are in order from low to high: Clubs, Diamonds, Hearts and Spades. The card values from low to high: 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King, and Ace. Write a Deck class that contains 52 cards. The class needs a method named shuffle that...
JavaScript C13
Question 1 (1 point)
Which property of the Number object returns the largest positive
value that JavaScript can represent?
Question 1 options:
MIN_VALUE
MAX_VALUE
POSITIVE_INFINITY
NEGATIVE_INFINITY
Save
Question 2 (1 point)
If a numerical operation returns a number greater than the
largest possible JavaScript value, it returns
Question 2 options:
NaN
-NaN
Infinity
-Infinity
Save
Question 3 (1 point)
In JavaScript, NaN represents
Question 3 options:
a value that isn’t a number
the largest positive value that can...
Create a function named getInput In the function create an object variable. The object variable should be named studentInfo Retrieve the values of the INPUT elements using appropriate document.getElementById function calls and store them in the attributes of the studentInfo object. After you have retrieved the values of the INPUT fields and stored them in variables, use an alert to display the value of the studentInfo.name attribute.
Write a class named Card which will represent a card from a deck of cards. A card has a suit and a face value. Suits are in order from low to high: Clubs, Diamonds, Hearts and Spades. The card values from low to high: 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King, and Ace. Write a Deck class that contains 52 cards. The class needs a method named shuffle that randomly shuffles the cards in the...
Write code to create a two-dimensional array named numbers containing 500 random numbers from 1 to 1000 inclusive. The array has 50 rows. Then walk through the array and output the random numbers 10 to a line. Format the numbers in right-aligned columns. Use the command prompt window for output. Note: do NOT create a class or main.