Exercises for Objects | javascript | 24
"use strict";
// java script array problem solved thinking
// Exampall 1
let squar = {
ground: 10,
height: 10,
get khetroFol() {
return 1.5 * this.ground * this.height
}
}
// console.log(squar.khetroFol);
// Exampall 2
let sentence = ['this ', 'is', 'concat ', 'name ', 'use', 'with out ', 'array ', 'concat()', ];
function conCat(sentence, ...val) {
let allCon = '';
sentence.forEach((val2, f) => {
if (f == val2.length - 1) {
allCon += val2;
} else {
allCon += val2 + val
}
})
return allCon;
}
// console.log(conCat(sentence));
// Exampall 3
let number = [12, 33, 44, 64, 24, 56];
let first1 = number[0];
// console.log(first1);
let second2 = number[1];
// console.log(secend2);
let third3 = number[2];
// console.log(third3);
let other4 = number.slice(3)
// console.log(other4);
// latest after ES - 6
let [first, second, third, ...others] = [12, 33, 44, 64, 24, 56];
// console.log(first);
// console.log(second);
// console.log(third);
// console.log(others);
// Exampall 4
// 1 house make 6 stik , more... house make how much stik
function houseNumber(num) {
if (num <= 0) {
let b = 0
return b
} else {
let a = (6 * num) - --num;
return a
}
}
console.log(houseNumber(-1))
console.log(houseNumber(1))
console.log(houseNumber(4))
console.log(houseNumber(100))