졸꾸 코딩일기 21.6.28

건강관리

  • 산책 - 비
  • 스트레칭 V
  • 감사일기 V

코딩기록

Javascript 코플릿 H - 12

function a(obj1, obj2) {
  for(let key1 in obj1){
    for(let key2 in obj2){
      if(obj1[key2] === undefined){
        obj1[key2] = obj2[key2]
      }
    }
  }
}
function b(obj, property) {
  if(Array.isArray(obj[property])){
    return obj[property].pop()
  }
}
function c(obj, key){
  if(Array.isArray(obj[key])){
    let arr1 = obj[key]
    return arr1.slice(0, arr1.length-1)
  }else{
    return []
  }
}
function f(arr, num) {
  if(arr.length === 0){
    return 'no name'
  }
  if(num < arr.length){
    return arr[num]['name']
  }else{
    return arr[arr.length-1]['name']
  }
}
function s(str) {
 let result = {} 
  for(let i = 0; i < str.length; i++){ 
    let strKeyIn = str[0]
    let count = 0;
    if(str[i] !== strKeyIn){
     strKeyIn = str[i]
    }
  for(let j = 0; j < str.length; j++){
     if(str[j] === strKeyIn){
        count = count + 1
       }
    }
    result[strKeyIn] = count
  }
  return result
}

좋은 웹페이지 즐겨찾기