sexta-feira, 6 de janeiro de 2017

Javascript exemplo2 - try/catch com funções internas

Segue exemplo 2 com try/catch em javascript.

<!DOCTYPE html>
<html>
<head><title>Usando Funções internas</title>
</head>
<body>

<h2> Exemplo1</h2>
<script>
  try{
  var x=a;
  var b= x+10;
  alert(b);
}
catch (e){
alert(e.toString());}
finally{
document.write("Fim");}
</script>
<hr/>

<h2> Exemplo2</h2>
<script>
var x = prompt("Informe o valor maior que 10");
try{
if (x<10){
throw "Numero menor que 10";}
alert(x);
}
catch (e){
alert(e);}
finally{
document.write("Fim");}
</script>
<hr/>
</body>
</html>
---------------------------------------------------------------------

Nenhum comentário:

Postar um comentário