Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var sam = [1, 2, 3, 4, 7, 3, 2, 5];
- var sedia = [1, 2, 3];
- var saluti = ['ciao', 'buongiorno', 'buonasera'];
- //console.log(sam.indexOf(100));
- // console.log(saluti.indexOf('ciao'));
- function isPari(elem){
- if (elem % 2 == 0){
- return true;
- }
- return false;
- }
- function test(elem){
- return (elem % 5 == 0 || elem == 7);
- }
- function sommaPari(acc, val) {
- if (val % 2 == 0){
- return acc + val;
- } else {
- return acc;
- }
- }
- function sum(acc, val){
- return acc + val;
- }
- console.log('somma=' + sedia.reduce(sum, 0));
- function stampa(numero, indice) {
- console.log("elemento " + numero + " in posizione " + indice);
- }
- function stampaSePari(val) {
- if (val % 2 == 0) {
- console.log(val);
- }
- }
- function meno100(val) {
- console.log(val-100);
- }
- // sam.forEach(stampaSePari);
- // sam.forEach(meno100);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement