Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Mini challenge to correct all the errors
- function useMagnifyingGlass():void{ //1. change from string to void - not return anything
- console.log('I will use my magnifying glass.')
- }
- function determineCulprit(){
- return Math.floor(Math.random()*2+1)
- }
- function doSleuthing(numberOfClues:number, clue1:string, clue2:string, suspect1, suspect2):void{ //2. Remove types for suspect1 & suspect2
- console.log('I am a famous detective and I will solve the crime.');
- let unnecessaryVariable = 'Why is this here?'
- // unnecessaryVariable=useMagnifyingGlass(); // 3. Comment or remove this unnecessary line
- console.log('Now I consider the first clue: ',clue1);
- console.log('Now I consider the second clue: ',clue2); //4. should be clue2 not clue1
- let culpritNumber:number = determineCulprit(); //5. Should be type number not string
- console.log('Now, I will return to you the culprit. There but for the grace of God go we.' );
- if(culpritNumber == 1) {return(suspect1)}
- if(culpritNumber == 2) {return(suspect2)}
- console.log("I couldn't figure out who drank the priceless milk. :( :(") //6. Change to console.log instead of return
- }
- let answer; //7. remove =3;
- //8. first argument should be number not '2'
- answer=doSleuthing(2, 'The parrot heard everything!', 'All the doors and windows were shut from the INSIDE.', 'Burglar Bob', 'Saint Sam')
- console.log('The culprit was none other than ', answer, '!');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement