SPSS Sum – Cautionary Note

Summary In SPSS, SUM(v1,v2) is not always equivalent to v1 + v2. This tutorial explains the difference and shows how to make the right choice here. Different Ways of Taking Sums have Different Outcomes when Missing Values are Present Explanation In SPSS, v1 + v2 + v3 will result in a system missing value if at least one missing value is present in v1, […]

JavaScript Array Iteration Methods

Array iteration methods operate on every array item. Array.forEach() The forEach() method Calls a function once for each array element. Example var txt = “”; var numbers = [4, 9, 16, 25]; numbers.forEach(myFunction); function myFunction(value, index, array) { txt = txt + item + “<br>”; } Try it Yourself » Note that the function takes 3 arguments: The item value The item index […]

JavaScript Array Methods

Converting Arrays to Strings The JavaScript method toString() converts an array to a string of (comma separated) array values. Example var fruits = [“Banana”, “Orange”, “Apple”, “Mango”]; document.getElementById(“demo”).innerHTML = fruits.toString(); Result Banana,Orange,Apple,Mango Try it Yourself » The join() method also joins all array elements into a string. It behaves just like toString(), but in addition you can specify the separator: Example var fruits = [“Banana”, “Orange”, “Apple”, “Mango”]; […]

JavaScript Number Methods

Number methods help you work with numbers. Number Methods and Properties Primitive values (like 3.14 or 2014), cannot have properties and methods (because they are not objects). But with JavaScript, methods and properties are also available to primitive values, because JavaScript treats primitive values as objects when executing methods and properties. The toString() Method toString() returns […]

JavaScript String Methods

String methods help you to work with strings. String Methods and Properties Primitive values, like “John Doe”, cannot have properties or methods (because they are not objects). But with JavaScript, methods and properties are also available to primitive values, because JavaScript treats primitive values as objects when executing methods and properties. String Length The length property returns […]