aboutsummaryrefslogtreecommitdiff
path: root/challenge-119/james-smith/javascript/ch-1.js
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-119/james-smith/javascript/ch-1.js')
-rw-r--r--challenge-119/james-smith/javascript/ch-1.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/challenge-119/james-smith/javascript/ch-1.js b/challenge-119/james-smith/javascript/ch-1.js
new file mode 100644
index 0000000000..4608fb09a1
--- /dev/null
+++ b/challenge-119/james-smith/javascript/ch-1.js
@@ -0,0 +1,9 @@
+TESTS = [ [101,86],[18,33] ];
+
+TESTS.forEach(_ => console.log( swap_nibble( _[0] ) == _[1] ? 'OK' : '--' ) );
+TESTS.forEach(_ => console.log( swap_nibble( _[1] ) == _[0] ? 'OK' : '--' ) );
+
+function swap_nibble(_) {
+ return (_>>4) | ((_&15)<<4);
+}
+