10 Days of JavaScript (Day 6) HackerRank Solutions #10daysofjavascript

 DAY 6: Bitwise Operators

Solution >>>

function getMaxLessThanK(n, k) {

  let max = 0;

  for (let i = 1; i <= n; i++) {

    for (let j = i + 1; j <= n; j++) {

      (i & j) > max && (i & j) < k ? (max = i & j) : max;

    }

  }

  return max;

}




DAY 6: JavaScript Dates

Solution >>>

function getDayName(dateString) {

  let dayName;

  const days = [

    "Sunday",

    "Monday",

    "Tuesday",

    "Wednesday",

    "Thursday",

    "Friday",

    "Saturday"

  ];

  dayName = days[new Date(dateString).getUTCDay()];

  return dayName;

}

Comments

Popular posts from this blog

Introduction to the Internet of Things and Embedded Systems (Week 2)

The Arduino Platform and C Programming (Week 1)