Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

objects

//// Write a function that takes an array of objects (courses) and returns object of 2 new arrays // first one is containing the names of all of the courses in the data set. // second one is containing the names of all the students
const getInfo = (arr) => {
  let coursesName = [];
  let studentsName = [];
  // write your code here

  return { coursesName, studentsName };
};

//if you find this answer is useful ,
//upvote ⇑⇑ , so can the others benefit also . @mohammad alshraideh ( ͡~ ͜ʖ ͡°)
Comment

objects

//There are 2 main ways to create an Object in JavaScript

//The First Method:
let firstPlayer = new Object();

//You can add properties like this:
firstPlayer.name = 'Player 1';
firstPlayer.level = 3;
firstPlayer.inventory = ['a half-eaten cracker', 'some pocket lint', 'a flimsy tree branch'];
firstPlayer.description = 'Don't mention Player 2 around them, they'll get angry...';

//You can create methods like this:
firstPlayer.checkLevel = function() {
    console.log(`${this.name} is currently... Level ${this.level}!`);
    //The "this" keyword refers to the object
}

firstPlayer.checkLevel();
//This will print "Player 1 is currently... Level 3!" to the Console


//The Second Method:
let secondPlayer = {
    
    //You can add properties like this:
    name: 'Player 2',
    level: 20,
    inventory: ['a health potion', 'a sack of gold coins', 'a sturdy steel blade'],
    description: 'Better than Player 1 in every way possible.',
    
    //You can create methods like this:
    checkLevel: function() {
        console.log(`${this.name} is currently... Level ${this.level}!`);
        //The "this" keyword refers to the object
    }
}

secondPlayer.checkLevel();
//This will print "Player 2 is currently... Level 20!" to the Console

//And that's it! Decide what method you prefer and start making some Objects!
Comment

PREVIOUS NEXT
Code Example
Javascript :: add multiple images inside the DOM js 
Javascript :: update text react native 
Javascript :: is there an api for netflix shows 
Javascript :: mdn react 
Javascript :: simple website with html css and javascript 
Javascript :: cheerio each 
Javascript :: Using the Set object 
Javascript :: save image on cloudinary 
Javascript :: set active element javascript 
Javascript :: python to java script 
Javascript :: where to create service angularor nodejs 
Javascript :: how to declare objects inside arrays in javascript 
Javascript :: array of array of string js 
Javascript :: jquery padding top 
Javascript :: how to interrupt scroll with jquery 
Javascript :: create immutable object in javascript 
Javascript :: Detect Mobile / Computer by Javascript 
Javascript :: findOne 
Javascript :: javascript string problems 
Javascript :: arange 
Javascript :: javascript Remove Element from Outer Array 
Javascript :: windows 10 retiré le theme sombre explorateur 
Python :: jupyter ignore warnings 
Python :: shebang for python linux 
Python :: matplotlib is required for plotting when the default backend "matplotlib" is selected. 
Python :: to_csv without index 
Python :: python get current directory 
Python :: check the os in python 
Python :: resize imshow opencv python 
Python :: conda create environment 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =