# CommonEdge Interview with Tigran ### If you could program in any language, what would it be? Javascript ### Why doesn't 0.4 + 0.8 == 1.2? (in javascript, Java, PHP, C, etc.) ### Fix the bugs in this function to count reachable nodes in a directed graph. ```php= class Node { public $value; public $children; // Node[] // count how many nodes are reachable from this node including this node public countNodes($seen=[]) { $n = 1; foreach ($seen as $object) { if ($object == $this) { return 0; } } $seen[] = $this; foreach($this->children as $child) { $n += $child->countNodes(&$seen); } return $n; } } ``` ### Given an array of numbers, return the second greatest number without using sort. ```php= $array = [1,2,3]; function getSecondGreatest($array) { $max = 0; $secondMax = 0; foreach ($array as $key => $value) { if($value > $max) { if($max > $secondMax){ $secondMax = $max; } $max = $value; }elseif($value > $secondMax){ $secondMax = $value; } } return $secondMax; } getSecondMax($array); ``` ### What is this function? ```typescript= const somemysteryfunction = <A,B>(f: (x: A) => B, xs: A[]): B[] => // ...