This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Employee { | |
constructor(name, daysWorked) { | |
this.name = name; | |
this.daysWorked = daysWorked; | |
} | |
calculatePay() { | |
const dailyPay = 100; // let's assume daily pay is 100 | |
return this.daysWorked * dailyPay; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const scores = [50, 6, 100, 0, 10, 75, 8, 60, 90, 80, 0, 30, 110]; | |
//Any scores that are below 10 needs to be multiplied by 10 and the new value included. | |
const boostSingleScores = scores.map(function (val) { | |
return (val < 10) ? val *10 : val; | |
}) | |
//Remove any scores that are over 100. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var firstname = "MyNamew"; | |
(function(name){ | |
var greeting = "Inside IIFE: Hellow" | |
console.log(greeting + '' + name); | |
}(firstname)) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return ( | |
<Card> | |
<form> | |
<h2> How you rate your service with us?</h2> | |
<div className={'input-group'}> | |
<input | |
onChange={handleTextChange} | |
type={'text'} | |
placeholder={'Write a review'} | |
value={text}/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const showComments = true; | |
function App() { | |
return ( | |
<div className='container'> | |
<h1>Blog Post</h1> | |
{showComments ? (<div className='comments'> | |
<h3>Comments ({comments.length})</h3> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const comments = [ | |
{id: 1, text: 'Comment One'}, | |
{id: 2, text: 'Comment Two'}, | |
{id: 3, text: 'Comment Three'}, | |
] | |
function App() { | |
return ( | |
<div className='comments'> | |
<h3>Comments ({comments.length})</h3> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let cases = { | |
'firstName' : 'FirstName', | |
'lastName' : 'LastName', | |
'email': '[email protected]', | |
'salary': 500235 | |
} | |
const verifiedEmail = !!cases["email"].match(/([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$/) | |
// OR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Rectangle extends Shape { | |
constructor(width, height){ | |
super(); | |
this.width = width; | |
this.height = height; | |
} | |
getArea(){ | |
return this.width * this.height; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let cases = { | |
'firstName' : 'FirstName', | |
'lastName' : 'LastName', | |
'email': '[email protected]', | |
'salary': 500235 | |
} | |
const verifiedEmail = !!cases["email"].match(/([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$/) | |
// OR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present']; | |
const result = words.filter(word => word.length > 6); | |
const containsE = words.filter(word => word.match(/[e]/g) ); | |
console.log(containsE); | |
console.log(result); |
NewerOlder