//nested loop // function countNumber(number) { // let count = 0 // for (let i = 0; i < number; i++) { // for (let j = 0; j < number; j++) { // count++ // } // } // console.log(count) // } // countNumber(12) //input - output //Time complexity - How much time it should take //o(1)- O(n)-o(n2) (Efficiency) // function isExist(arr, num) { // let isFound = false // for (let numElm of arr) { // if (numElm === num) { // isFound = true // break // } // } // return isFound // } // console.log(isExist([1, 2, 3, 4, 5], 10)) //if all elements of of numArr exists on arr // function isExist(arr, numArr) { // console.log(numArr) // let resultArr = [] // for( arr of numArr ){ // console.log(arr) // resultArr.push(...arr) // } // console.log(resultArr) // const truthy = [] // for (let num of numArr) { // let found = false // console.log(num) // for (let elm of arr) { // if (num === elm) { // found = true // break // } // } // truthy.push(found) // } // console.log(truthy) // return truthy.every((val) => val) // } // console.log(isExist([1, 2, 3, 4, 5], [1, 2]) // function isExist(arr, numArr) { // let truthyOrFalsy = [] // for (let num of numArr) { // const isIncluded = arr.includes(num) // truthyOrFalsy.push(isIncluded) // } // return truthyOrFalsy.every((elm) => elm) // } // console.log(isExist([1, 2, 3, 4, 5], [1, 2, 10])) // function countOccurence(arr, searchElm) { // let count = 0 // for (let num of arr) { // if (searchElm === num) { // count++ // } // } // console.log(count) // } // countOccurence([1, 3, 5, 7, 10, 1], 1) //{ // '1': 2, // '3': 1, // '5':1 // } // function countOccurence(arr) { // const obj = {} // for (let num of arr) { // console.log(num) // if (obj[num]) { // obj[num]++ // } else { // obj[num] = 1 // } // } // let max = 0 // for(let prop in obj){ // if(obj[prop] > max){ // max = obj[prop] // } // } // console.log(obj,max) // let max = 0 // let maxChar = '' // for (let prop in obj) { // if (obj[prop] > max) { // max = obj[prop] // maxChar = prop // } // } // console.log(obj, max, maxChar) // } // countOccurence(['a', 'b', 'c', 'd', 'a', 'a']) //reverseString // function reverStr(str) { // // return str.split('').reverse().join('') // let resultStr = '' // for (let i = str.length - 1; i >= 0; i--) { // console.log(i) // console.log(str[i]) // resultStr += str[i] // } // return resultStr // } // console.log(reverStr('samim'))