Intro
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
useEffect(() => { | |
async function omdbAPIRequest() { | |
const requests = inventory.map((inventoryItem) => { | |
return axios.get( | |
`http://www.omdbapi.com/?i=${inventoryItem.id}&apikey=7f539340` | |
); | |
}); | |
const responses = await Promise.allSettled(requests); | |
const responseDatas = responses.map((response) => response.value.data); |
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
// primitives are 'passed by value' in JS | |
// meaning the value of the variable is copied over into a new local variable in the function | |
let n = 1; | |
function addOne(x) { | |
x += 1; | |
return x; | |
} |
Sure, here's a programming assignment for teaching the basics of regular expressions in Javascript:
In this assignment, you will be using regular expressions to validate and manipulate strings in Javascript.
Create a function validateEmail(email)
that takes an email address as input and returns true
if the email address is valid and false
otherwise. An email address is considered valid if it meets the following criteria:
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
/** | |
* The main thing to see here is the 'optimal substructure' i.e. | |
* perms([1, 2, 3]) could benefit from first knowing the result of | |
* perms([1, 2]), which in turn could use perms([1]) as a starting point | |
* and our basest of cases would be perms([]) at which point we have a | |
* trivial problem (so was perms([1]) but I like to accoutn for empty). | |
* | |
* This points us to a helper function we are going to need, spread. | |
* spread will 'spread' a single value into all possible array positions | |
* at the previous level. So our logic is something like: |
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
import Data.List (inits, tails) | |
main :: IO () | |
main = do | |
print $ perms [1..4] | |
print $ perms' "abcd" | |
print $ perms'' [Nothing, Just 1, Just 2, Just 3] | |
perms, perms', perms'' :: [a] -> [[a]] |
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
// Product Model definition, called 'product' and associated with table 'products' | |
var Product = this.sequelize.define('product', { | |
title: Sequelize.STRING | |
}); | |
// User Model definition, called 'user' and associated with table 'users' | |
var User = this.sequelize.define('user', { | |
first_name: Sequelize.STRING, | |
last_name: Sequelize.STRING | |
}); |
NewerOlder