{"size": 886, "ext": "js", "max_stars_repo_path": "PasswordDecrypt.js", "max_stars_repo_name": "see-why/HackerRank-and-LeetCode-Solutions", "max_stars_repo_stars_event_min_datetime": "2022-02-22T08:48:52.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-03T22:31:16.000Z", "max_issues_repo_path": "PasswordDecrypt.js", "max_issues_repo_name": "see-why/HackerRank-Solutions", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "PasswordDecrypt.js", "max_forks_repo_name": "see-why/HackerRank-Solutions", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 5, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 21.6097560976, "max_line_length": 85, "alphanum_fraction": 0.4097065463}
function decryptPassword(s) {
    // Write your code here    
    let find= '*';
    let replace = '';
    
    while( s.indexOf(find) > -1)
    {
       var s = s.replace(find, replace);
    }
    
    let index = s.split('').findIndex(item => /[A-Z|a-z]/i.test(item));
    
    let i=0, r = s.slice(0,index);
    r = r.split('')
    s = s.slice(index, s.length).split('')
    
    while( s.indexOf('0') > -1){
        let post =  s.indexOf('0')
        s[post] =  r.pop() 
    }
    
    
    let pattern = /[A-Z]/
    let pattern_lower = /[a-z]/
    
    
     for (let i=s.length-1; i<=0 ; i--){
        if(isNaN(s[i])){
            if((i+1) < s.length && pattern.test(s[i]) && pattern_lower.test(s[i-1])){
                let temp = s[i]
                s[i] = s[i-1]
                s[i-1] = temp
                i -= 1
            }
        }
    }
    
    return s.join('')

}
