We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Hiring developers?
  1. Prepare
  2. Tutorials
  3. 30 Days of Code
  4. Day 26: Nested Logic
  5. Discussions

Day 26: Nested Logic

Problem
Submissions
Leaderboard
Discussions
Editorial
Tutorial

    You are viewing a single comment's thread. Return to all comments →

  • teymurnasir
    3 months ago+ 0 comments

    JavaScript Solution

    function processData(input) {
        //Enter your code here
        
        
        var date_returned = input.split("\n")[0].split(" ")
        var date_due = input.split("\n")[1].split(" ")
        
        calculateFee(date_returned.map(Number),date_due.map(Number));
    
    } 
    
    function calculateFee(date_returned,date_due){
        
        var hackos= 0; 
        
        if(date_returned[2]>date_due[2]){
            hackos= 10000;
        }else if(date_returned[1]>date_due[1] && date_returned[2]===date_due[2]){
            hackos= 500*(date_returned[1]-date_due[1]);
        }else if(date_returned[0] > date_due[0] && date_returned[1]===date_due[1] && date_returned[2]===date_due[2]){
            hackos = 15*(date_returned[0]-date_due[0]);
        }
        
        console.log(hackos);
    }
    
    0|
    Permalink
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy