437,636 Members | 1,207 Online Need help? Post your question and get tips & solutions from a community of 437,636 IT Pros & Developers. It's quick & easy.

# Doing Calculations with arrays

 P: n/a I'm pretty noobish to javascript I want to make algorithms that take selections from arrays and put them together in new ways. here is a simple array I set up for notes of a piano keyboard: what I want to do is: 1) enable the user to select a "starting note" (that is the key) 2) enable the user to select a scale, that is, a "path" through these notes. If the user selects major, the program will, starting from the selected starter note, choose thenext notes according to this pattern: Root (the key selected) + 2 + 2 + 1 + 2 + 2 + 2 + 1 so if the user selects "C" and "major scale," it will print: C, D, E, F, G, A, B, C 3) I want the program to "create" chords from the notes in the scale generated. like this: I = 1 + 3 + 5 = C chord = C + E + G II = 2 + 4 + 6 = D chord = D + F + A III = 3 + 5 + 7 = E chord = E + G + B IV = 4 + 6 + 1 = F chord = F + A + C V = 5 + 7 + 2 = G chord = G + B + D VI = 6 + 1 + 3 = A chord = A + C + E VII= 7 + 2 + 4 = B chord = B + D + F I need help with: a) can somebody give me hints on how to code the algorithms that would do this? b) could somebody point me in the directions of a set of snippets that might help me on this? Have mercy, I am a n00b, not begging for a handout, but for help. thanks Sep 12 '06 #1
4 Replies

 P: n/a "outstretchedarm" Notes.htm
The "Scale" dropdown does nothing -- yet. You lost me with: 3) I want the program to "create" chords from the notes in the scale generated. like this: I = 1 + 3 + 5 = C chord = C + E + G II = 2 + 4 + 6 = D chord = D + F + A III = 3 + 5 + 7 = E chord = E + G + B IV = 4 + 6 + 1 = F chord = F + A + C V = 5 + 7 + 2 = G chord = G + B + D VI = 6 + 1 + 3 = A chord = A + C + E VII= 7 + 2 + 4 = B chord = B + D + F Sep 12 '06 #2

 P: n/a outstretchedarm wrote: 1) enable the user to select a "starting note" (that is the key) 2) enable the user to select a scale, that is, a "path" through these notes. If the user selects major, the program will, starting from the selected starter note, choose thenext notes according to this pattern: Root (the key selected) + 2 + 2 + 1 + 2 + 2 + 2 + 1 so if the user selects "C" and "major scale," it will print: C, D, E, F, G, A, B, C I am no way a specialist of any kind in music, so I was going by the formal description only (I hope I got it right). It may help to start - given that someone else may propose a better starting point and/or further steps. Notes

Sep 12 '06 #3

 P: n/a WOW!!!!! This is really awesome! I have been trying to do this for days! you don't know how grateful I am! i will study this code and try to glean as much understanding as I can from it. can someone point me in the direction of learning more about arrays, since that is where I am doing most of my research? Sep 12 '06 #4

 P: n/a JRS: In article , dated Tue, 12 Sep 2006 15:19:14 remote, seen in news:comp.lang.javascript, McKirahan Here's a start. Watch for word-wrap. Word-wrap is YOUR responsibility. Javascript should not be written in the manner that you write VBScript. IMHO, neither should VBScript. var html = "
" + "Notes: \n"; html += "\n"; var itm2 = (note+","+note+","+note).split(","); should for legibility be written, in News, as var itm2 = (note + "," + note + "," + note).split(","); Javascript should only be used to write invariant parts of HTML if those parts are both smallish and surrounded by parts which must be computed. It's a good idea to read the newsgroup and its FAQ. -- © John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 © ? JL/RC: FAQ of news:comp.lang.javascript

### This discussion thread is closed

Replies have been disabled for this discussion. 