Last active
December 15, 2015 21:14
-
-
Save lazywithclass/6b6a14699aeed656e55e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// review https://gist.github.com/lazywithclass/f42aab0ca8af0f17d5e8 | |
// strings | |
// operations on strings | |
// given a string like this | |
// "1+2-5" | |
// use the above functions implemented in the exercise | |
// to provide the result | |
function suddividi(operazione) { | |
return operazione.split('+'); | |
} | |
function somma(a, b) { | |
return parseInt(a, 10) + parseInt(b, 10); | |
} | |
function calcolatrice(operazione) { | |
var suddivisa = suddividi(operazione); | |
return somma(suddivisa[0], suddivisa[1]); | |
} | |
// far funzionare | |
// suggerimento, usa sempre split, niente altro | |
// calcolatrice("1+2+3") | |
// calcolatrice("7+14+2") | |
// in modo che restituisca 6 | |
// calcolatrice("1+2-3") | |
// calcolatrice("16+23-13") | |
// in modo che restituisca 6 | |
// calcolatrice("1+2*3") | |
// in modo che restituisca 6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment