// Code Block
const readOnlyObj = {
a: number = 1,
b: number = 2
} as const;
.container {
display: flex;
align-items: center;
justify-content: center;
width:100%;
height:100%
}
.container > div {
width:100px;
height:100px;
}
function sanitiseString(str){
str = str.replace(/[^a-z0-9áéíóúñü \.,_-]/gim,"");
return str.trim();
}
function sanitizeEmail(str) {
var entityMap = {
'&': '&',
'<': '<',
'>': '>',
'"': '"',
"'": ''',
'/': '/',
'`': '`',
'=': '='
};
return String(str).replace(/[&<>"'`=\/]/g,
function (s) {
return entityMap[s];
}
);
}
function getCount(str) {
var count = 0;
for(var i = 0; i < str.length; i++){
console.log(str.charAt(i))
switch(str.charAt(i)){
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
count++;
break;
}
}
return count;
}
function findShort(s){
const wordArr = s.split(" ")
var short = 0 for (var i = 0; i < wordArr.length; i++) {
const word = wordArr[i].length;
short = short === 0 ? word : (word <= short ? word : short)
}
return short
}
function openOrSenior(data){
// ... check data
if(data.length > 0){
for(var i=0; i<data.length; i++){
var item = data[i];
var ins = "Open";
if(item[0] >= 55 && item[1] > 7) {
ins = "Senior";
}
result.push(ins);
}
}
return result;
}
function addBinary(a,b) {
var intVal = a + b;
return Number(intVal).toString(2);
}
var isSquare = function(n){
const test = Math.sqrt(n) % 1 === 0;
return test;
}
const arr = [1,2,3,4,5,6,7,8,22];
arr.reduce((a, b) => Math.max(a,b));
const obj = {
name: 'GillCode',
age: 30,
language: 'JavaScript'
};
const values = Object.values(obj); // values
const keys = Object.keys(obj); // keys
const entries = Object.entries(obj); // entries in [][]