Basic 2 Flashcards
do two lines without template strings (es5) and both methods.
html = ‘<ul><li>Name: ‘ + name + ‘</li><li>Age: ‘ + age + ‘ </li><li>Job: ‘
html = ‘<ul>’ +
‘<li>Name: ‘ + name + ‘</li>’ +
‘<li>Age: ‘ + age + ‘</li>’ +</ul></li></ul>
The formula of template strings (es6)
html = ` <ul> <li>Name: ${name}</li> <li>Age: ${age}</li> </ul> `;
What you can do in (es6 template)?
You can do expressions, show functions, and add if statements as well.
what it’s the console.log for html document?
document.body.innerHTML = html
what arrays can do ?
they allow to store multiple values in one value, they can be muted and the can be used in some really complex alghoritmens
What are the 2 ways of creat an array? show the formula.
const numbers = [43,56,33,23,44,36,5]; const numbers2 = new Array(22,45,33,76,54);
What kind of information can be within an array?
const mixed = [ 22, ‘Hello’, true, undefined, null, {a:1, b:1}, new Date()];
Type the formulas for:
- Get array length
- Check if is array
- Get single value
- Find index of value
- Add on to end
- Add on to front
- Take off from end
- Take off from front
- Splice values
- Reverse
- Concatenate array
- Sorting arrays
val = numbers.length; val = Array.isArray(numbers); val = numbers[3]; val = numbers.indexOf(36); numbers.push(250); numbers.unshift(120); numbers.pop(); numbers.shift(); numbers.splice(); numbers.reverse(); val = numbers.concat(numbers2); val = fruit.sort();
What is the ‘COMPRE FUNCTION’ formula ?
val = numbers.sort(function(x, y){
return x - y;
});
What is the ‘FIND function formula?
Find function under50(num){ return num < 50; }
val = numbers.find(under50)