![Ironhack](https://camo.githubusercontent.com/9de24c4b16b211890f8a4b9db074b26a284cd3c54e739c6852641607bfc9520e/68747470733a2f2f73332d65752d776573742d312e616d617a6f6e6177732e636f6d2f69682d6d6174657269616c732f75706c6f6164732f75706c6f61645f36653137316564633332336234646633306165316631636566653633633765322e706e67)
var language = prompt('Please select a language');
if (language === 'portuguese') {
console.log('Olá mundo!');
} else if (language == 'french') {
console.log('Bonjour tout le monde');
} else {
console.log('Hello, world!');
}
var language = prompt('Please select a language');
switch(language) {
case 'portuguese':
console.log('Olá mundo!')
break;
case 'french':
console.log('Bonjour tout le monde');
break;
default:
console.log('Hello, world!');
}
var i = 1;
while (i <= 30) {
console.log(i);
i = i + 1;
}
var i = 1;
while (i <= 30) {
if (i === 10) {
console.log('Ten')
} else if (i === 20) {
console.log('Twenty')
} else {
console.log(i);
}
i = i + 1;
}
for(var i = 1; i<=30; i++) {
console.log(i);
}
for(var i = 1; i<=30; i++) {
if (i === 10) {
console.log('Ten')
} else if (i === 20) {
console.log('Twenty')
} else {
console.log(i);
}
}
function getComputerChoice() {
Math.floor(Math.random() * 3);
var randomNumber = Math.floor(Math.random() * 3);
switch (randomNumber) {
case 0:
return 'rock';
break;
case 1:
return 'paper';
break;
case 2:
return 'scissors';
break;
}
}
function determineWinner(userChoice, computerChoice) {
if (userChoice === computerChoice) {
return 'The game was a tie.';
}
if (userChoice === 'rock') {
if (computerChoice === 'paper') {
return 'The computer has won';
} else {
return 'You have won!'
}
}
if (userChoice === 'paper') {
if (computerChoice === 'scissors') {
return 'The computer has won'
} else {
return 'You have won!'
}
}
if (userChoice === 'scissors') {
if (computerChoice === 'paper') {
return 'You have won!'
} else {
return 'The computer has won'
}
}
}
function getUserChoice() {
var userChoice = prompt("Do you choose rock, paper or scissors?");
return userChoice;
}
function playGame() {
var computerChoice = getComputerChoice();
var userChoice = getUserChoice();
console.log('You threw ' + userChoice);
console.log('The computer threw ' + computerChoice);
console.log(determineWinner(userChoice, computerChoice));
}
playGame();