JS - Objects - Basic Problems #86
Replies: 25 comments
-
let programming = {
languages: ["JavaScript", "Python", "Ruby"],
isChallenging: true,
isRewarding: true,
difficulty: 8,
jokes: "http://stackoverflow.com/questions/234075/what-is-your-best-programmer-joke"
};
// console.log(programming);
// 1️⃣Write the command to add the language "Go" to the end of the languages array.
let languages = programming.languages;
languages.push("Go");
console.log(languages);
// 2️⃣Change the difficulty to the value of 7.
programming.difficulty = 7;
console.log(programming.difficulty);
// 3️⃣Using the delete keyword, write the command to remove the jokes key from the programming object.
delete programming.jokes;
console.log(programming);
// 4️⃣Write the command to add a new key called isFun and a value of true to the programming object.
programming.isFun = true;
console.log(programming);
// 5️⃣Using a loop, iterate through the languages array and console.log all of the languages.
for(key in programming.languages){
console.log(languages[key]);
}
// 6️⃣Using a loop, console.log all of the keys in the programming object.
for(key in programming){
console.log(key);
}
// 7️⃣Using a loop, console.log all of the values in the programming object.
for(key in programming){
console.log(programming[key]);
} |
Beta Was this translation helpful? Give feedback.
-
let programming = {
languages: ["JavaScript", "Python", "Ruby"],
isChallenging: true,
isRewarding: true,
difficulty: 8,
jokes: "http://stackoverflow.com/questions/234075/what-is-your-best-programmer-joke"
};
//Write the command to add the language "Go" to the end of the languages array.
programming.languages.push("Go")
//Change the difficulty to the value of 7.
programming.difficulty = 7
//Using the delete keyword, write the command to remove the jokes key from the programming object.
delete programming.jokes
//Write the command to add a new key called isFun and a value of true to the programming object.
programming.isFun = true
//Using a loop, iterate through the languages array and console.log all of the languages.
for (key in programming.languages){
console.log(programming.languages[key])
}
//Using a loop, console.log all of the keys in the programming object.
for (key in programming){
console.log(key)
}
//Using a loop, console.log all of the values in the programming object.
for (key in programming){
console.log(programming[key])
} |
Beta Was this translation helpful? Give feedback.
-
let programming = {
languages: ["JavaScript", "Python", "Ruby"],
isChallenging: true,
isRewarding: true,
difficulty: 8,
jokes: "http://stackoverflow.com/questions/234075/what-is-your-best-programmer-joke"
};
//Q:1 Write the command to add the language "Go" to the end of the languages array.
programming.languages.push("Go");
console.log(programming);
//Q:2 Change the difficulty to the value of 7.
programming.difficulty = 7;
console.log(programming);
//Q:3 Using the delete keyword, write the command to remove the jokes key from the programming object.
delete programming.jokes;
console.log(programming);
//Q:4 Write the command to add a new key called isFun and a value of true to the programming object.
programming.Fun = "true";
console.log(programming); |
Beta Was this translation helpful? Give feedback.
-
let programming = {
languages: ["JavaScript", "Python", "Ruby"],
isChallenging: true,
isRewarding: true,
difficulty: 8,
jokes: "http://stackoverflow.com/questions/234075/what-is-your-best-programmer-joke"
};
// Question 1
programming.languages.push('Go');
console.log(programming);
console.log();
//Question 2
programming.difficulty = 7;
console.log(programming);
console.log();
//Question 3
delete programming.jokes;
console.log(programming);
console.log();
//Question 4
programming.isFun = true;
console.log(programming);
console.log();
//Question 5
for(key in programming.languages){
console.log(programming.languages[key]);
}
console.log();
//Question 6
for(i in programming){
console.log(i+" : "+programming[i]);
}
console.log();
//Question 7
for(j in programming){
console.log(programming[j]);
} |
Beta Was this translation helpful? Give feedback.
-
let programming = {
languages: ["JavaScript", "Python", "Ruby"],
isChallenging: true,
isRewarding: true,
difficulty: 8,
jokes:
"http://stackoverflow.com/questions/234075/what-is-your-best-programmer-joke",
};
//adding the language "Go" to the end of the languages array.
programming.languages.push("Go");
console.log(programming);
console.log();
// changing the value of the key(difficulty)
programming.difficulty = 7;
console.log(programming);
// Removing the key-jokes from object
delete programming.jokes;
console.log(programming);
// adding new key and value to the object
programming.isFun = true;
console.log(programming);
// Using a loop, iterate through the languages array and console.log all of the languages.
for (key in programming.languages) {
console.log(programming.languages[key]);
}
//Using a loop, console.log all of the keys in the programming object.
for (i in programming) {
console.log(i + " : " + programming[i]);
}
console.log();
//Using a loop, console.log all of the values in the programming object.
for (j in programming) {
console.log(programming[j]);
}Result |
Beta Was this translation helpful? Give feedback.
-
let programming = {
languages: ["JavaScript", "Python", "Ruby"],
isChallenging: true,
isRewarding: true,
difficulty: 8,
jokes: "http://stackoverflow.com/questions/234075/what-is-your-best-programmer-joke"
};
programming.languages.push("Go");
console.log(programming);
programming.difficulty ='7';
console.log(programming);
delete(programming.jokes);
console.log(programming);
programming.isFun = 'true';
console.log(programming);
for(let key of programming.languages){
console.log(key);
}
for(let key in programming){
console.log(key);
}
for(let key in programming){
console.log(programming[key]);
} |
Beta Was this translation helpful? Give feedback.
-
let programming = {
languages: ["JavaScript", "Python", "Ruby"],
isChallenging: true,
isRewarding: true,
difficulty: 8,
jokes: "http://stackoverflow.com/questions/234075/what-is-your-best-programmer-joke"
};
let languages = programming.languages;
languages.push("Go");
console.log(languages);
programming.difficulty = 7;
console.log(programming.difficulty);
delete programming.jokes;
console.log(programming);
programming.isFun = true;
console.log(programming);
for(key in programming.languages){
console.log(languages[key]);
}
for(key in programming){
console.log(key);
}
for(key in programming){
console.log(programming[key]);
} |
Beta Was this translation helpful? Give feedback.
-
let programming = {
languages: ["JavaScript", "Python", "Ruby"],
isChallenging: true,
isRewarding: true,
difficulty: 8,
jokes: "http://stackoverflow.com/questions/234075/what-is-your-best-programmer-joke"
};
// 1)Write the command to add the language "Go" to the end of the languages array.
let languages=programming.languages;
languages.push("Go");
console.log(languages);
// 2)Change the difficulty to the value of 7.
programming.difficulty=7;
console.log(programming.difficulty);
// 3)Using the delete keyword, write the command to remove the jokes key from the programming object.
console.log(delete programming.jokes);
console.log(programming);
// 4)Write the command to add a new key called isFun and a value of true to the programming object.
programming.isFun=true;
console.log(programming);
// 5)Using a loop, iterate through the languages array and console.log all of the languages.
for(key in programming.languages){
console.log(languages[key]);
}
//6) Using a loop, console.log all of the keys in the programming object.
for(let key in programming){
console.log(key);
}
//7) Using a loop, console.log all of the values in the programming object.
for(let key in programming){
console.log( programming[key]);
}
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
let programming = {
languages: ["JavaScript", "Python", "Ruby"],
isChallenging: true,
isRewarding: true,
difficulty: 8,
jokes: "http://stackoverflow.com/questions/234075/what-is-your-best-programmer-joke"
};
programming.languages.push("Go");
console.log(programming);
programming.difficulty = 7;
console.log(programming.difficulty);
delete programming.jokes;
console.log(programming);
programming.isFun = true;
console.log(programming);
for(key in programming.languages){
console.log(programming.languages[key]);
}
for(key in programming){
console.log(key);
}
for(key in programming){
console.log(programming[key]);
} |
Beta Was this translation helpful? Give feedback.
-
let programming = {
languages: ["JavaScript", "Python", "Ruby"],
isChallenging: true,
isRewarding: true,
difficulty: 8,
jokes: "http://stackoverflow.com/questions/234075/what-is-your-best-programmer-joke"
};
//Question 1
console.log("the command to add the language 'Go' to the end of the languages array.")
programming.languages.push("Go")
console.log(programming.languages)
//Question 2
console.log("\nChange the difficulty to the value of 7.")
programming.difficulty = 7;
console.log(programming.difficulty)
//Question 3
console.log("\ncommand to remove the jokes key from the programming object.")
delete programming.jokes;
console.log(programming)
//Question 4
console.log("\ncommand to add a new key called isFun and a value of true to the programming object.")
programming.isFun = true
console.log(programming.isFun)
//Question 5
console.log("\niterate through the languages array and console.log all of the languages.")
for (let key in programming.languages)
{
console.log(programming.languages[key]+",")
}
//Question 6
console.log("\nconsole.log all of the keys in the programming object.")
for (let key1 in programming)
{
console.log(key1+",")
}
//Question 7
console.log("\nconsole.log all of the values in the programming object.")
for (let key1 in programming)
{
console.log(programming[key1]+",")
}
|
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
let programming = {
languages: ["JavaScript", "Python", "Ruby"],
isChallenging: true,
isRewarding: true,
difficulty: 8,
jokes: "http://stackoverflow.com/questions/234075/what-is-your-best-programmer-joke"
};
programming.languages.push("GO") ;
console.log(programming.languages);
programming.difficulty = 7;
console.log(programming["difficulty"]);
delete programming.jokes;
console.log(programming.jokes);
programming.isFun = true;
console.log(programming);
for(let key in programming.languages){
console.log(programming.languages[key]);
}
for(let key in programming){
console.log(key);
}
for(let key in programming){
console.log(programming[key]);
} |
Beta Was this translation helpful? Give feedback.
-
let programming = {
languages: ["JavaScript", "Python", "Ruby"],
isChallenging: true,
isRewarding: true,
difficulty: 8,
jokes: "http://stackoverflow.com/questions/234075/what-is-your-best-programmer-joke"
};
//1. Write the command to add the language "Go" to the end of the languages array.
console.log(programming.languages);
programming.languages.push("go")
console.log(programming.languages)
//2. Change the difficulty to the value of 7.
programming.difficulty =7;
console.log(programming.difficulty);
//3. Using the delete keyword, write the command to remove the jokes key from the programming object.
delete programming.jokes;
console.log(programming);
//4. Write the command to add a new key called isFun and a value of true to the programming object.
programming.isFun = true;
console.log(programming);
//5. Using a loop, iterate through the languages array and console.log all of the languages.
for (key in programming.languages){
console.log(programming.languages[key]);
}
//6. Using a loop, console.log all of the keys in the programming object
for (key in programming){
console.log(key)
}
//7. Using a loop, console.log all of the values in the programming object
for (key in programming){
console.log(programming[key]);
} |
Beta Was this translation helpful? Give feedback.
-
let programming = {
languages: ["JavaScript", "Python", "Ruby"],
isChallenging: true,
isRewarding: true,
difficulty: 8,
jokes: "http://stackoverflow.com/questions/234075/what-is-your-best-programmer-joke"
};
//1
programming.languages.push("Go");
//2
programming.difficulty = 7 ;
//3
delete programming.jokes;
//4
programming.isFun = true ;
//5
for(let i = 0 ; i < programming.languages.length ; i++){
console.log(programming.languages[i]);
}
//6
for(let x of Object.keys(programming)){
console.log(x);
}
//7
for(let x of Object.values(programming)){
console.log(x);
} |
Beta Was this translation helpful? Give feedback.
-
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
let programming = {
languages: ["JavaScript", "Python", "Ruby"],
isChallenging: true,
isRewarding: true,
difficulty: 8,
jokes: "http://stackoverflow.com/questions/234075/what-is-your-best-programmer-joke"
};
//1
programming.languages[3]="Go";
for (let i = 0; i < programming.languages.length; i++) {
document.write(programming.languages[i]);
}
//2
programming.difficulty =7;
document.write(programming.difficulty);
//3
delete programming.jokes;
for (let key in programming) {
document.write(key);
}
//4
programming.isfun="true";
//5
for(let key in programming)
{
document.write(key);
}
//6
for(let i=0; i < programming.languages.length; i++)
{
console.log(programming.languages[i]);
}
//7
for(key in programming)
{
console.log(programming[key]);
}
</script>
</body>
</html> |
Beta Was this translation helpful? Give feedback.
-
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
let programming = {
languages: ["JavaScript", "Python", "Ruby"],
isChallenging: true,
isRewarding: true,
difficulty: 8,
jokes: "http://stackoverflow.com/questions/234075/what-is-your-best-programmer-joke"
};
//1
programming.languages.push("go");
console.log(programming.languages);
//2
programming.difficulty=7;
//3
delete programming.jokes;
//4
console.log(programming);
//5
programming.isfun=true;
console.log(programming)
//6
for(let l of programming.languages){
console.log("languages "+l);
}
//7
for(i in programming){
console.log(i+" : "+programming[i]);
}
console.log();
</script>
</body>
</html>`` |
Beta Was this translation helpful? Give feedback.
-
1-7 let programming = {
languages: ["JavaScript", "Python", "Ruby"],
isChallenging: true,
isRewarding: true,
difficulty: 8,
jokes: "http://stackoverflow.com/questions/234075/what-is-your-best-programmer-joke"
};
programming.languages.push("go");
console.log(programming.languages);
programming.difficulty = 7;
console.log(programming)
delete programming.jokes;
console.log(programming);
programming["isFun"] = true;
console.log(programming)
for(let i of programming.languages){
console.log("languages-> " + i);
}
for(keys in programming){
console.log(`keys-> ${keys}`);
}
for(keys in programming){
console.log(`values ->${programming[keys]}`)
} |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
|
let programming = { programming.languages.push("Go"); // Answer 1. console.log(); programming.difficulty = 7; // Answer 2. console.log(); delete programming.jokes; // Answer 3. console.log(); programming.isFun = true; // Answer 4. console.log(); // Answer 5. console.log(); // Answer 6. console.log(); // Answer 7. |
Beta Was this translation helpful? Give feedback.
-
|
let programming = { for (key in programming){ |
Beta Was this translation helpful? Give feedback.
-
/* Task:86 https://github.com/akash-coded/mern/discussions/86 */
let programming = {
languages: ["JavaScript", "Python", "Ruby"],
isChallenging: true,
isRewarding: true,
difficulty: 8,
jokes:
"http://stackoverflow.com/questions/234075/what-is-your-best-programmer-joke",
};
//1. Write the command to add the language "Go" to the end of the languages array.
let lang = programming.languages;
lang.push("Go");
console.log(lang);
console.log();
//2. Change the difficulty to the value of 7.
console.log(programming.difficulty + " before changing the difficulty");
programming.difficulty = 7;
console.log(programming.difficulty + " after changing the difficulty");
console.log();
//3. Using the delete keyword, write the command to remove the jokes key from the programming object.
delete programming.jokes;
console.log(programming);
//4. Write the command to add a new key called isFun and a value of true to the programming object.
console.log();
programming.isFun = true;
console.log(programming);
//5.Using a loop, iterate through the languages array and console.log all of the languages.
console.log();
for (let i = 0; i < programming.languages.length; i++) {
console.log(programming.languages[i]);
}
console.log();
//6. Using a loop, console.log all of the keys in the programming object.
for (key in programming) {
console.log(key);
}
console.log();
//7. Using a loop, console.log all of the values in the programming object
for (values in programming) {
console.log(programming[values]);
} |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.


























Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
For each of the exercises below, assume you are starting with the following
programmingobject.Beta Was this translation helpful? Give feedback.
All reactions