function askID(type) {
    inquirer.prompt([
        {
        type: 'number',
        message: `What is their ID #?`,
        name: 'ID',
        },
    ]).then(({ID}) => {
        if(listID.includes(ID) || Number.isNaN(ID)) {
            if(Number.isNaN(ID)) {
                console.log(ck.red(`ERROR: Not a number!`)); } else {
                console.log(ck.red(`ERROR: ID#${ID} is already in use!`));
            }
            askID(type);  //using recursion until a valid answer is given
        } else {
            listID.push(ID);
            switch (type) {
                case 'Manager':
                    addManager(ID);                    
                    break;
                case 'Engineer':
                    addEngineer(ID);                    
                    break;
                case 'Intern':
                    addIntern(ID);                    
                    break;          
                default:
                    break;
            }
        }
    });
}
//using this function to require a valid ID that is unique
using this function to require a valid ID that is unique
using this function to require a valid ID that is unique
function askID(type) {
    inquirer.prompt([
        {
        type: 'number',
        message: `What is their ID #?`,
        name: 'ID',
        },
    ]).then(({ID}) => {
        if(listID.includes(ID) || Number.isNaN(ID)) {
            if(Number.isNaN(ID)) {
                console.log(ck.red(`ERROR: Not a number!`)); } else {
                console.log(ck.red(`ERROR: ID#${ID} is already in use!`));
            }
            askID(type);  
        } else {
            listID.push(ID);
            switch (type) {
                case 'Manager':
                    addManager(ID);                    
                    break;
                case 'Engineer':
                    addEngineer(ID);                    
                    break;
                case 'Intern':
                    addIntern(ID);                    
                    break;          
                default:
                    break;
            }
        }
    });
}
function askID ( type ) { inquirer . prompt ( [ { type : 'number' , message : ` ` , name : 'ID' , } , ] ) . then ( ( { ID } ) => { if ( listID . includes ( ID ) || Number . isNaN ( ID ) ) { if ( Number . isNaN ( ID ) ) { console . log ( ck . red ( ` ` ) ) ; } else { console . log ( ck . red ( ` ${ ID } ` ) ) ; } askID ( type ) ; } else { listID . push ( ID ) ; switch ( type ) { case 'Manager' : addManager ( ID ) ; break ; case 'Engineer' : addEngineer ( ID ) ; break ; case 'Intern' : addIntern ( ID ) ; break ; default : break ; } } } ) ; }
using this function to require a valid ID that is unique
using this function to require a valid ID that is unique
//using recursion until a valid answer is given