Question

In: Computer Science

JavaScript Given the following object, log every property name and value to the console using a...

JavaScript

Given the following object, log every property name and value to the console using a loop.

let myObj = {
    id: 12
    name: 'My Object',
    class: 'obj',
    height: 65,
    likeJavascript: true,
    data: [1, 53, 23]
};
  

Solutions

Expert Solution

Find the code for the above question below, read the comments provided in the code for better understanding. If found helpful please do upvote this.
Please refer to the screenshot of the code to understand the indentation of the code.

To loop a objects use the Object.keys() method , it returns all the keys in an object which can be used to iterate

Code

//Given object

let myObj = {

id: 12,

name: 'My Object',

class: 'obj',

height: 65,

likeJavascript: true,

data: [1, 53, 23]

};

//use the OBject.keys() methods

Object.keys(myObj).forEach(a=>{

//log the key and value

console.log("Property Name : ",a," , Value : ",myObj[a])

})

Screenshot

Output


Related Solutions

Write a log-in log-out session using PHP, CSS, and HTML only. NO MYSQL and JavaScript allowed....
Write a log-in log-out session using PHP, CSS, and HTML only. NO MYSQL and JavaScript allowed. 1. Need an HTML form and a login form; separate file. 2. need a CSS file to make it look good 3. Must store visitors' info in a .txt file and validate from there if the user exists before granting access to the dashboard. If the user does not exist, render the form to signup. If the user exists take them to their dashboard....
Given the following information regarding an income producing property, determine the net present value using unlevered...
Given the following information regarding an income producing property, determine the net present value using unlevered cash flows at a discount rate of 10%. Expected Holding Period: 5 years; 1st year Expected NOI: $91,200; 2nd year Expected NOI: $93,873; 3rd year Expected NOI: $96,626; 4th year Expected NOI: $99,462; 5th year Expected NOI: $102,383; 6th Expected NOI: 105,634; Debt Service in each of the next five years: $60,544; Current Market Value: $897,000; Required equity investment: $223,350; Apply a going-out capitalization...
Which of the following is/are true about JavaScript object properties? A. To use dot notation, a...
Which of the following is/are true about JavaScript object properties? A. To use dot notation, a property name must be a valid JavaScript identifier B. All properties are automatically locally scoped but may be accessed by using ‘prototype’ C. Variables declared with var inside constructor functions are locally scoped and cannot be directly accessed as properties D. Variables declared with var inside constructor functions are globally scoped E. Properties that contain boolean values may not be accessed with bracket notation...
[Javascript] Create a function(returnObjectFromId(case, ...idNum)) to return the case Object(s) for a given idNum, or list...
[Javascript] Create a function(returnObjectFromId(case, ...idNum)) to return the case Object(s) for a given idNum, or list of idNums. Calling with a single `idNum` value should return the case Object, and return NULL if an id value that's unknown is passed returnObjectFromId(case, 84838) would return the Object in the cases Array with an 'idNumber' of id, and use the .find() method of the cases Array to locate items by idNumber. returnObjectFromId(cases, -23298312) would return null. returnObjectFromId(cases, 161020, 161021) would return an...
Q-1) a client wants to log into a server by using username and password first name...
Q-1) a client wants to log into a server by using username and password first name a suitable http mechanism like cookie or session to make it happen and then make a signal flow diagram to show that how does it happen
Javascript Problem: List Reverse Given a list: var list = { value: 1, next: { value:...
Javascript Problem: List Reverse Given a list: var list = { value: 1, next: { value: 2, next: { value: 3, next: null } } }; Reverse the order of the list so that it looks like: var list = { value: 3, next: { value: 2, next: { value: 1, next: null } } }; Use the following shell if needed: //assignment1.js function reverseList(list) { // your code here ... return reversedList; } Example Test Case(s): Arguments: { value:...
USING JAVASCRIPT Create a file name dayOfWeek.js and write an arrow function named dayOfWeek that accepts...
USING JAVASCRIPT Create a file name dayOfWeek.js and write an arrow function named dayOfWeek that accepts a Date object dateStr and returns a string that is the day of the week in English form (i.e. “Sunday”, “Monday”, etc.). Test your function by creating a date object that is a significant date to you (such as your birthday) and passing that date object to your function. Test your function at least twice with two different dates. Submit the dayOfWeek.js file to...
which of the following best describes the mass of an object? a. A physical property and...
which of the following best describes the mass of an object? a. A physical property and intensive property b. A chemical and intensive property c. An intensive and extensive property d. An extensive property and physical property
The Coase Theorem is a name often given to an argument that property rights or liability...
The Coase Theorem is a name often given to an argument that property rights or liability rules will generally be sufficient to manage what have conventionally been referred to as “external effects” (externalities) efficiently. Describe Coase’s argument, including the reciprocal nature of the problem as he outlined it, and the claim that outcomes will be independent of the allocation of rights/liabilities. Outline some of the limitations to the claim that private bargaining will achieve efficient outcomes.
1.the object of a tax, which may include income, property, the value of goods sold is...
1.the object of a tax, which may include income, property, the value of goods sold is defined as the tax rate tax base tax activity tax fee 2. which of the following is a tax on wealth? income tax property tax sales tax excise tax 3. In judging the merits of a tax it is important to consider if the tax burden is justly distributed(equity) if the tax burden improves the allocation of resources it the tax is enforceable all...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT