This file contains hidden or 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
/* Poiščite node.js modul na npmjs.com, ga namestite v okolju runnable.com in ga | |
uporabite. Naredite funkcijo, ki iz datoteke prebere števila in jih sešteje med seboj.*/ | |
var fs = require('fs'); | |
var numbers = '0, 1, 3.9, -5, 100 \n200, 300 \n-50'; | |
fs.writeFileSync('file', numbers); | |
function sum(file_name) { | |
var x = fs.readFileSync(file_name, 'utf-8').split(/[\n,]+/); | |
return x.reduce(function(a, b){return parseFloat(a) + parseFloat(b)}); |
This file contains hidden or 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
/*----------------------------------------------------------- | |
1.naloga: izpis propertyjev lastnika popravi tako, da bodo izpisani tudi propertyji ljubljenčka. | |
-----------------------------------------------------------*/ | |
console.log('1. naloga'); | |
console.log('\n'); | |
var owner = { | |
species: 'cat', | |
name: 'Pebbles', | |
'favourite food': 'lasagna', |
This file contains hidden or 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
//1. naloga | |
var amount = 99.99; | |
console.log(2*amount+"€"); | |
//2. naloga | |
alert("Help me fix this program!"); | |
alert("Can you get this message to appear?"); | |
document.write("<h2>My first JavaScript program</h2>"); | |
document.write("<p>I'm practicing 'debugging'.</p>"); | |
var age = prompt("What\'s your age?"); |